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
packagecom.exampleclassMutableTableContainer {
privatevar_table:Map<String, Int>?=nullval table:Map<String, Int>
get() {
if (_table==null) {
_table= hashMapOf()
}
return_table?:throwAssertionError("Set to null by another thread")
}
}
Diktat 1.2.5 warns:
MutableTableContainer.kt:7:9: [CUSTOM_GETTERS_SETTERS] custom getters and setters are not recommended, use class methods instead: get (cannot be auto-corrected) (diktat-ruleset:custom-getter-setter)
Probably we should make an exception for property accessors/modifiers whenever there's a backing field with the corresponding name (xyz → _xyz) and of the same type.
Describe the bug
Consider this idiomatic example taken directly from https://kotlinlang.org:
Diktat 1.2.5 warns:
Probably we should make an exception for property accessors/modifiers whenever there's a backing field with the corresponding name (
xyz
→_xyz
) and of the same type.Related:
VARIABLE_NAME_INCORRECT_FORMAT
false positive when a property has a backing field #1711Expected behavior
No warning should have been reported.
Observed behavior
A warning was reported.
Steps to Reproduce
Check the above code example with Diktat.
Environment information
The text was updated successfully, but these errors were encountered: