Skip to content

Commit

Permalink
UseDataClass: fix false positive on value classes (#4016)
Browse files Browse the repository at this point in the history
* UseDataClass: fix false positive on value classes

* Simplify test snippet
  • Loading branch information
cortinico committed Aug 7, 2021
1 parent 6a3ccdd commit 8abb138
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -125,7 +125,8 @@ class UseDataClass(config: Config = Config.empty) : Rule(config) {
klass.isEnum() ||
klass.isAnnotation() ||
klass.isSealed() ||
klass.isInline()
klass.isInline() ||
klass.isValue()

private fun hasOnlyPrivateConstructors(klass: KtClass): Boolean {
val primaryConstructor = klass.primaryConstructor
Expand Down
Expand Up @@ -326,6 +326,14 @@ class UseDataClassSpec : Spek({
assertThat(subject.lint("inline class A(val x: Int)")).isEmpty()
}

it("does not report value classes") {
val code = """
@JvmInline
value class A(val x: Int)
""".trimIndent()
assertThat(subject.lint(code)).isEmpty()
}

it("does not report a class which has an ignored annotation") {
val code = """
import kotlin.SinceKotlin
Expand Down

0 comments on commit 8abb138

Please sign in to comment.