ktlint icon indicating copy to clipboard operation
ktlint copied to clipboard

Properties that start with `_` should be suppressed by `PropertyName`

Open Goooler opened this issue 1 year ago • 1 comments

Expected Behavior

No errors are thrown.

Observed Behavior

ktlint Foo.kt
/Users/goooler/StudioProjects/DemoApp/adapter/src/main/kotlin/io/goooler/demoapp/adapter/rv/core/Foo.kt:4:17: Backing property not allowed when 'private' modifier is missing (standard:backing-property-naming)
/Users/goooler/StudioProjects/DemoApp/adapter/src/main/kotlin/io/goooler/demoapp/adapter/rv/core/Foo.kt:4:17: Backing property is only allowed when a matching property or function exists (standard:backing-property-naming)

Summary error count (descending) by rule:
  standard:backing-property-naming: 2

Steps to Reproduce

Foo.kt:

open class Foo {

  @Suppress("PropertyName")
  protected val _bar = mutableListOf<String>()
}

Run ktlint Foo.kt.

Context

Related to:

  • #2332
  • #2612

Your Environment

  • Version of ktlint used: CLI 1.3.0

Goooler avatar Jun 25 '24 07:06 Goooler

@Suppress(PropertyName) currently only suppresses the property-naming rule (code).

paul-dingemans avatar Jun 25 '24 12:06 paul-dingemans