diktat
diktat copied to clipboard
`IdentifierNaming` rule `VARIABLE_HAS_PREFIX` does not check for keywords
Describe the bug
This inspection removes a single letter prefix (e.g. mFunction
--> function
).
It does not check if the resulting property/variable name is a keyword (e.g. kClass
--> class
) which generates invalid code which further inspections will trip over and fail with an exception.
Expected behavior
The inspection generates valid code (imho not renaming affected properties) if the renaming would result in a language keyword.
Observed behavior
com.pinterest.ktlint.core.ParseException: 17:8 Expecting property name or receiver type
on a subsequent inspection because it fails to parse the code.
Steps to Reproduce
Environment information
- diktat version: 1.1.0
- build tool (gradle): 7.4.2
- how is diktat run (CLI, plugin, etc.): spotless
- kotlin version: 1.6.20
- operating system: windows/ubuntu
Thank you for the report! That should be easy to fix :)