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

Report UseDataClass findings on class name #5352

Merged
merged 1 commit into from Sep 25, 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 @@ -102,7 +102,7 @@ class UseDataClass(config: Config = Config.empty) : Rule(config) {
report(
CodeSmell(
issue,
Entity.from(klass),
Entity.from(klass.nameIdentifier ?: klass),
"The class ${klass.nameAsSafeName} defines no " +
"functionality and only holds data. Consider converting it to a data class."
)
Expand Down
Expand Up @@ -153,11 +153,16 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) {
inner class `does report data class candidates` {

@Test
fun `does report a data class candidate`() {
fun `does report a data class candidate on the class name`() {
val code = """
class DataClassCandidate1(val i: Int)
""".trimIndent()
assertThat(subject.compileAndLint(code)).hasSize(1)

val findings = subject.compileAndLint(code)

assertThat(findings).hasSize(1)
assertThat(findings).hasStartSourceLocation(1, 7)
assertThat(findings).hasEndSourceLocation(1, 26)
}

@Test
Expand Down