saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
521 stars 39 forks source link

`IdentifierNaming` rule `VARIABLE_HAS_PREFIX` does not check for keywords #1285

Open HaukeRa opened 2 years ago

HaukeRa commented 2 years ago

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

orchestr7 commented 2 years ago

Thank you for the report! That should be easy to fix :)