Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BooleanPropertyNaming highlight only the name of the variable #5431

Merged
merged 2 commits into from Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -79,7 +79,7 @@ class BooleanPropertyNaming(config: Config = Config.empty) : Rule(config) {
val description = "Boolean property name should match a $allowedPattern pattern."
return CodeSmell(
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
issue,
Entity.from(declaration),
Entity.atName(declaration),
message = "$description Actual name is $name"
)
}
Expand Down
Expand Up @@ -254,6 +254,24 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) {

assertThat(findings).isEmpty()
}

@Test
fun `should highlight only the name`() {
val code = """
data class Test(
/**
* True if the user's e-mail address has been verified; otherwise false.
*/
@Deprecated("Don't use this", replaceWith = ReplaceWith("email_verified"))
BraisGabin marked this conversation as resolved.
Show resolved Hide resolved
val emailVerified: Boolean?,
)
""".trimIndent()
val findings = subject.compileAndLintWithContext(env, code)

assertThat(findings)
.hasSize(1)
.hasTextLocations("emailVerified")
}
}

@Nested
Expand Down Expand Up @@ -617,6 +635,24 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) {
assertThat(BooleanPropertyNaming(config).compileAndLint(code))
.isEmpty()
}

@Test
fun `should highlight only the name`() {
val code = """
class Test {
/**
* True if the user's e-mail address has been verified; otherwise false.
*/
@Deprecated("Don't use this", replaceWith = ReplaceWith("email_verified"))
var emailVerified: Boolean? = false
}
""".trimIndent()
val findings = subject.compileAndLintWithContext(env, code)

assertThat(findings)
.hasSize(1)
.hasTextLocations("emailVerified")
}
}
}

Expand Down