Skip to content

Commit

Permalink
Suppress backing-property-naming rule with `@Suppress("LocalVariabl…
Browse files Browse the repository at this point in the history
…eName")` (#2785)

* Suppress `backing-property-naming` rule with `@Suppress("LocalVariableName")`

* Suppress `backing-property-naming` rule with `@Suppress("LocalVariableName")`

Closes #2779
  • Loading branch information
paul-dingemans authored Sep 3, 2024
1 parent 71cfaaa commit 9ba1d0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ internal class SuppressionLocator(
"RemoveCurlyBracesFromTemplate" to listOf("standard:string-template"),
"ClassName" to listOf("standard:class-naming"),
"FunctionName" to listOf("standard:function-naming"),
"LocalVariableName" to listOf("standard:backing-property-naming"),
"PackageName" to listOf("standard:package-name"),
"PropertyName" to listOf("standard:property-naming", "standard:backing-property-naming"),
"ConstPropertyName" to listOf("standard:property-naming"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,17 @@ class BackingPropertyNamingRuleTest {
""".trimIndent()
backingPropertyNamingRuleAssertThat(code).hasNoLintViolations()
}

@Test
fun `Issue 2779 - Given a property name suppressed via 'LocalVariableName' then also suppress the ktlint violation`() {
val code =
"""
@Suppress("LocalVariableName")
fun test() {
val _test = "test"
println(_test)
}
""".trimIndent()
backingPropertyNamingRuleAssertThat(code).hasNoLintViolations()
}
}

0 comments on commit 9ba1d0c

Please sign in to comment.