You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a class has two properties which are conceptually the same but one is part of a public API and another is an implementation detail, use an underscore as the prefix for the name of the private property:
When a backing property is needed, its name should exactly match that of the real property except prefixed with an underscore. Android Kotlin style guide is less explicit:
When a backing property is needed, its name should exactly match that of the real property except prefixed with an underscore.
Several users have requested to loosen the restrictions regarding the modifier of the base property:
As Originally posted by @paul-dingemans in #2345 (comment) the solution could be to split the property-naming rule and extract part of the logic to a new rule backing-property. Requirements:
property-naming rule should ignore properties for which the name starts with _ as this will be handled by backing-property rule
backing-property rule will be identical to logic which is currently implemented in property-naming in case of intellij_idea or ktlint_official code styles. In case of android_studio code style, the modifier is ignored.
The text was updated successfully, but these errors were encountered:
Extract `backing-property-name` from `property-naming` rule. This allows users to disable this rule, but keep the `property-naming` rule in place.
For `android_studio` code style the restrictions regarding the modifier of the correlated property or function is ignored entirely as the Android Kotlin Styleguide does not require it to be public.
Closes#2528
…2552)
Extract `backing-property-name` from `property-naming` rule. This allows users to disable this rule, but keep the `property-naming` rule in place.
For `android_studio` code style the restrictions regarding the modifier of the correlated property or function is ignored entirely as the Android Kotlin Styleguide does not require it to be public.
Closes#2528
The
property-naming
also contains logic to check backing properties.Kotlin Coding Conventions clear states that:
When a backing property is needed, its name should exactly match that of the real property except prefixed with an underscore. Android Kotlin style guide is less explicit:
Several users have requested to loosen the restrictions regarding the modifier of the base property:
As Originally posted by @paul-dingemans in #2345 (comment) the solution could be to split the
property-naming
rule and extract part of the logic to a new rulebacking-property
. Requirements:property-naming
rule should ignore properties for which the name starts with_
as this will be handled bybacking-property
rulebacking-property
rule will be identical to logic which is currently implemented inproperty-naming
in case ofintellij_idea
orktlint_official
code styles. In case ofandroid_studio
code style, the modifier is ignored.The text was updated successfully, but these errors were encountered: