diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGenerator.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGenerator.kt
index b1a9c51..c208787 100644
--- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGenerator.kt
+++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGenerator.kt
@@ -32,7 +32,7 @@ internal class HtmlReportGenerator(
*/
fun generate(writer: Writer, items: List, baseTicketUrl: String? = null) {
val (techDebtItems, suppressedItems, commentItems) = filterItems(items)
- val summary = calculateSummary(techDebtItems)
+ val summary = calculateSummary(techDebtItems, commentItems, suppressedItems)
writer.appendHTML().html {
appendHead(this)
@@ -56,13 +56,19 @@ internal class HtmlReportGenerator(
return Triple(techDebtItems, suppressedItems, commentItems)
}
- private fun calculateSummary(techDebtItems: List): SummaryData =
+ private fun calculateSummary(
+ techDebtItems: List,
+ commentItems: List,
+ suppressedItems: List
+ ): SummaryData =
SummaryData(
- total = techDebtItems.size,
+ total = techDebtItems.size + commentItems.size + suppressedItems.size,
high = techDebtItems.count { it.priority == "HIGH" },
medium = techDebtItems.count { it.priority == "MEDIUM" },
low = techDebtItems.count { it.priority == "LOW" },
- none = techDebtItems.count { it.priority == "NONE" }
+ none = techDebtItems.count { it.priority == "NONE" },
+ comments = commentItems.size,
+ suppressed = suppressedItems.size
)
private fun appendHead(html: HTML) {
@@ -102,7 +108,9 @@ internal class HtmlReportGenerator(
highItems = summary.high,
mediumItems = summary.medium,
lowItems = summary.low,
- noneItems = summary.none
+ noneItems = summary.none,
+ commentItems = summary.comments,
+ suppressedItems = summary.suppressed
)
appendActionButtons(this)
@@ -148,6 +156,8 @@ internal class HtmlReportGenerator(
val high: Int,
val medium: Int,
val low: Int,
- val none: Int
+ val none: Int,
+ val comments: Int,
+ val suppressed: Int
)
}
diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/ReportStyle.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/ReportStyle.kt
index 00393fe..ebb1ffd 100644
--- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/ReportStyle.kt
+++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/ReportStyle.kt
@@ -72,6 +72,8 @@ internal class ReportStyle {
.medium { background-color: #F5A623; }
.low { background-color: #4CAF50; }
.none { background-color: #9E9E9E; }
+ .comments { background-color: #1A237E; }
+ .suppressed { background-color: #607D8B; }
"""
.trimIndent()
diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/SummaryGenerator.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/SummaryGenerator.kt
index a6985e9..7de7881 100644
--- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/SummaryGenerator.kt
+++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/report/SummaryGenerator.kt
@@ -17,6 +17,8 @@ internal class SummaryGenerator {
* @param mediumItems the number of medium priority items
* @param lowItems the number of low priority items
* @param noneItems the number of items without priority
+ * @param commentItems the number of comment items
+ * @param suppressedItems the number of suppressed items
*/
@Suppress("LongParameterList")
fun append(
@@ -25,7 +27,9 @@ internal class SummaryGenerator {
highItems: Int,
mediumItems: Int,
lowItems: Int,
- noneItems: Int
+ noneItems: Int,
+ commentItems: Int,
+ suppressedItems: Int
) {
body.div(classes = "summary-container") {
div(classes = "summary-box total") {
@@ -48,6 +52,14 @@ internal class SummaryGenerator {
h2 { +noneItems.toString() }
span { +"No Priority" }
}
+ div(classes = "summary-box comments") {
+ h2 { +commentItems.toString() }
+ span { +"Comments" }
+ }
+ div(classes = "summary-box suppressed") {
+ h2 { +suppressedItems.toString() }
+ span { +"Suppressed" }
+ }
}
}
}
diff --git a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGeneratorTest.kt b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGeneratorTest.kt
index 5b1ada8..b54573d 100644
--- a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGeneratorTest.kt
+++ b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/report/HtmlReportGeneratorTest.kt
@@ -77,8 +77,9 @@ internal class HtmlReportGeneratorTest {
assertTrue(html.contains("Annotated Tech Debt"))
assertTrue(html.contains("Suppressed Rules"))
assertTrue(html.contains("Rule1"))
- // Suppressed item should not be counted in the summary
- assertTrue(html.contains("
1
"), "Should contain only 1 in summary total")
+ // Suppressed item should be counted in the summary total now
+ assertTrue(html.contains("
2
"), "Should contain total 2 in summary total")
+ assertTrue(html.contains("Suppressed"), "Should contain Suppressed in summary")
}
@Test
@@ -146,6 +147,28 @@ internal class HtmlReportGeneratorTest {
assertTrue(html.contains("Collapse All"))
}
+ @Test
+ fun `test generator counts comments and suppressed items in summary`() {
+ val items =
+ listOf(
+ createItem(module = "A", priority = "HIGH", type = TechDebtItemType.TECH_DEBT),
+ createItem(module = "A", priority = "NONE", type = TechDebtItemType.COMMENT),
+ createItem(module = "B", priority = "NONE", type = TechDebtItemType.COMMENT),
+ createItem(module = "C", priority = "NONE", type = TechDebtItemType.SUPPRESS)
+ )
+
+ val writer = StringWriter()
+ generator.generate(writer, items)
+ val html = writer.toString()
+
+ assertTrue(html.contains("
4
"), "Total items should be 4")
+ assertTrue(html.contains("
1
"), "High priority should be 1")
+ assertTrue(html.contains("
2
"), "Comments should be 2")
+ assertTrue(html.contains("
1
"), "Suppressed should be 1")
+ assertTrue(html.contains("Comments"), "Label 'Comments' should be present")
+ assertTrue(html.contains("Suppressed"), "Label 'Suppressed' should be present")
+ }
+
private fun createItem(
module: String,
priority: String,
4
+Comments