Skip to content

Commit

Permalink
Changes FindingsReporter detail level
Browse files Browse the repository at this point in the history
Achieved different levels of detailing by changing the format in the
implementation of compact() method for CodeSmell and
ThresholdedCodeSmell.
  • Loading branch information
gfreivasc committed Jan 9, 2022
1 parent 0669888 commit 954e741
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Expand Up @@ -24,7 +24,7 @@ open class CodeSmell(

override val id: String = issue.id

override fun compact(): String = "$id - ${entity.compact()}"
override fun compact(): String = "$id - ${messageWithLocation()}"

override fun compactWithSignature(): String = compact() + " - Signature=" + entity.signature

Expand All @@ -39,6 +39,8 @@ open class CodeSmell(
}

override fun messageOrDescription(): String = message.ifEmpty { issue.description }

private fun messageWithLocation() = "[${messageOrDescription()}] at ${location.compact()}"
}

/**
Expand Down Expand Up @@ -98,7 +100,9 @@ open class ThresholdedCodeSmell(
val threshold: Int
get() = metric.threshold

override fun compact(): String = "$id - $metric - ${entity.compact()}"
override fun compact(): String = "$id - $metric - ${messageWithLocation()}"

override fun messageOrDescription(): String = message.ifEmpty { issue.description }

private fun messageWithLocation() = "[${messageOrDescription()}] at ${location.compact()}"
}
6 changes: 3 additions & 3 deletions detekt-core/src/test/resources/reporting/findings-report.txt
@@ -1,7 +1,7 @@
Ruleset1 - 10min debt
TestSmell - [TestEntity] at TestFile.kt:1:1
TestSmell - [TestEntity] at TestFile.kt:1:1
TestSmell - [TestMessage] at TestFile.kt:1:1
TestSmell - [TestMessage] at TestFile.kt:1:1
Ruleset2 - 5min debt
TestSmell - [TestEntity] at TestFile.kt:1:1
TestSmell - [TestMessage] at TestFile.kt:1:1

Overall debt: 15min
@@ -1,7 +1,7 @@
File1.kt - 10min debt
TestSmell - [TestEntity] at File1.kt:1:1
TestSmell - [TestEntity] at File1.kt:1:1
TestSmell - [TestMessage] at File1.kt:1:1
TestSmell - [TestMessage] at File1.kt:1:1
File2.kt - 5min debt
TestSmell - [TestEntity] at File2.kt:1:1
TestSmell - [TestMessage] at File2.kt:1:1

Overall debt: 15min

0 comments on commit 954e741

Please sign in to comment.