From 5af71841d788496ff1b7d3cc06ed2848f6582fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brais=20Gab=C3=ADn?= Date: Thu, 12 May 2022 13:00:11 +0200 Subject: [PATCH] Improve issue description and smell message of DestructuringDeclarationWithTooManyEntries (#4795) --- .../style/DestructuringDeclarationWithTooManyEntries.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/DestructuringDeclarationWithTooManyEntries.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/DestructuringDeclarationWithTooManyEntries.kt index 780331db97a..d50f148909c 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/DestructuringDeclarationWithTooManyEntries.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/DestructuringDeclarationWithTooManyEntries.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.psi.KtDestructuringDeclaration * data class TooManyElements(val a: Int, val b: Int, val c: Int, val d: Int) * val (a, b, c, d) = TooManyElements(1, 2, 3, 4) * + * * * data class FewerElements(val a: Int, val b: Int, val c: Int) * val (a, b, c) = TooManyElements(1, 2, 3) @@ -29,8 +30,7 @@ class DestructuringDeclarationWithTooManyEntries(config: Config = Config.empty) override val issue = Issue( javaClass.simpleName, Severity.Style, - "The destructuring declaration contains too many entries, making it difficult to read. Consider refactoring " + - "to avoid using a destructuring declaration for this case.", + "Too many entries in a destructuring declaration make the code hard to understand.", Debt.TEN_MINS ) @@ -39,7 +39,9 @@ class DestructuringDeclarationWithTooManyEntries(config: Config = Config.empty) override fun visitDestructuringDeclaration(destructuringDeclaration: KtDestructuringDeclaration) { if (destructuringDeclaration.entries.size > maxDestructuringEntries) { - report(CodeSmell(issue, Entity.from(destructuringDeclaration), issue.description)) + val message = "The destructuring declaration contains ${destructuringDeclaration.entries.size} but only " + + "$maxDestructuringEntries are allowed." + report(CodeSmell(issue, Entity.from(destructuringDeclaration), message)) } super.visitDestructuringDeclaration(destructuringDeclaration) }