pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.06k stars 504 forks source link

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

Open Goooler opened 5 days ago

Goooler commented 5 days ago

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:

Your Environment

paul-dingemans commented 5 days ago

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