Skip to content

Commit

Permalink
Suppress property-naming rule
Browse files Browse the repository at this point in the history
When Intellij IDEA suppressions `ObjectPropertyName` or `PrivatePropertyName` are used, then also suppress ktlint `property-naming` rule.

Closes #2612
  • Loading branch information
paul-dingemans committed Apr 23, 2024
1 parent 9367b7e commit a156d9c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ internal object SuppressionLocatorBuilder {
"PackageName" to "standard:package-name",
"PropertyName" to "standard:property-naming",
"ConstPropertyName" to "standard:property-naming",
"ObjectPropertyName" to "standard:property-naming",
"PrivatePropertyName" to "standard:property-naming",
"UnusedImport" to "standard:no-unused-imports",
)
private val SUPPRESS_ANNOTATIONS = setOf("Suppress", "SuppressWarnings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,26 @@ class PropertyNamingRuleTest {
""".trimIndent()
propertyNamingRuleAssertThat(code).hasNoLintViolations()
}

@Test
fun `Issue 2612 - Given a property name suppressed via 'PrivatePropertyName' then also suppress the ktlint violation`() {
val code =
"""
class Foo {
@Suppress("PrivatePropertyName")
private val Bar = "Bar"
}
""".trimIndent()
propertyNamingRuleAssertThat(code).hasNoLintViolations()
}

@Test
fun `Issue 2612 - Given a property name suppressed via 'ObjectPropertyName' then also suppress the ktlint violation`() {
val code =
"""
@Suppress("ObjectPropertyName")
private const val _Foo_Bar = ""
""".trimIndent()
propertyNamingRuleAssertThat(code).hasNoLintViolations()
}
}

0 comments on commit a156d9c

Please sign in to comment.