Skip to content

Commit a514f20

Browse files
Improve the messaging for "DataClassFunctions"
1 parent 07f2572 commit a514f20

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/kotlin/com/github/ivy/explicit/rule/DataClassFunctionsRule.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class DataClassFunctionsRule(config: Config) : Rule(config) {
1111
override val issue = Issue(
1212
id = "DataClassFunctions",
1313
severity = Severity.Maintainability,
14-
description = "Data classes should not define behavior. " +
15-
"Their purpose is to model data.",
14+
description = "Data classes should not be tied to any behavior. " +
15+
"Their responsibility is to solely model data.",
1616
debt = Debt.TWENTY_MINS,
1717
)
1818

@@ -42,7 +42,7 @@ class DataClassFunctionsRule(config: Config) : Rule(config) {
4242
function: KtNamedFunction
4343
): String = buildString {
4444
append("Data class '${klass.name}' should not contain functions. ")
45-
append("Data classes should only model data and not define behavior. ")
46-
append("Found: function '${Message.functionSignature(function)}'.")
45+
append("Found: function '${Message.functionSignature(function)}'. ")
46+
append("Data classes should only model data and should not be tied to any behavior.")
4747
}
4848
}

src/test/kotlin/com/github/ivy/explicit/rule/DataClassFunctionsRuleTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class DataClassFunctionsRuleTest(private val env: KotlinCoreEnvironment
1414
@Test
1515
fun `reports data class having one function`() {
1616
val code = """
17-
data class A(
17+
data class Abc(
1818
val x: Int
1919
) {
2020
fun a() = 42
@@ -24,7 +24,7 @@ internal class DataClassFunctionsRuleTest(private val env: KotlinCoreEnvironment
2424
findings shouldHaveSize 1
2525
val message = findings.first().message
2626
message shouldBe """
27-
Data class 'A' should not contain functions. Data classes should only model data and not define behavior. Found: function 'a()'.
27+
Data class 'Abc' should not contain functions. Found: function 'a()'. Data classes should only model data and should not be tied to any behavior.
2828
""".trimIndent()
2929
}
3030

0 commit comments

Comments
 (0)