Skip to content

Commit

Permalink
StaticHtmlReporter: Limit the issue summary to unresolved issues
Browse files Browse the repository at this point in the history
As that is what is relevant to the user.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Mar 12, 2019
1 parent 0a39421 commit 6236278
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@
<h2>Index</h2>
<ul>
<li>
<a href="#rule-violation-summary">Rule Violation Summary (1 errors, 1 warnings, 1 hints)</a>
<a href="#rule-violation-summary">Rule Violation Summary (1 errors, 1 warnings, 1 hints to resolve)</a>
</li>
<li>
<a href="#issue-summary">Issue Summary (1 errors, 0 warnings, 0 hints)</a>
<a href="#issue-summary">Issue Summary (1 errors, 0 warnings, 0 hints to resolve)</a>
</li>
<li>
<a href="#Gradle:com.here.ort.gradle.example:lib:1.0.0">Gradle:com.here.ort.gradle.example:lib:1.0.0</a>
Expand All @@ -277,7 +277,7 @@ <h2>Index</h2>
<a href="#Gradle:com.here:nested-test-project:1.0.0">Gradle:com.here:nested-test-project:1.0.0</a>
</li>
</ul>
<h2 id="rule-violation-summary">Rule Violation Summary (1 errors, 1 warnings, 1 hints)</h2>
<h2 id="rule-violation-summary">Rule Violation Summary (1 errors, 1 warnings, 1 hints to resolve)</h2>
<table class="ort-report-table ort-violations">
<thead>
<tr>
Expand Down Expand Up @@ -305,7 +305,7 @@ <h2 id="rule-violation-summary">Rule Violation Summary (1 errors, 1 warnings, 1
</tr>
</tbody>
</table>
<h2 id="issue-summary">Issue Summary (1 errors, 0 warnings, 0 hints)</h2>
<h2 id="issue-summary">Issue Summary (1 errors, 0 warnings, 0 hints to resolve)</h2>
<p>Issues from excluded components are not shown in this summary.</p>
<h3>Packages</h3>
<table class="ort-report-table">
Expand Down
10 changes: 5 additions & 5 deletions reporter/src/main/kotlin/reporters/ReportTableModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ data class ReportTableModel(
data class IssueTable(
val rows: List<IssueRow>
) {
val allIssues = rows.flatMap {
val unresolvedIssues = rows.flatMap {
it.analyzerIssues.flatMap { (_, issues) -> issues } + it.scanIssues.flatMap { (_, issues) -> issues }
}.groupBy { it.severity }
}.filterNot { it.isResolved }.groupBy { it.severity }

val errorCount = allIssues[Severity.ERROR].orEmpty().count()
val warningCount = allIssues[Severity.WARNING].orEmpty().count()
val hintCount = allIssues[Severity.HINT].orEmpty().count()
val errorCount = unresolvedIssues[Severity.ERROR].orEmpty().count()
val warningCount = unresolvedIssues[Severity.WARNING].orEmpty().count()
val hintCount = unresolvedIssues[Severity.HINT].orEmpty().count()
}

data class IssueRow(
Expand Down
15 changes: 8 additions & 7 deletions reporter/src/main/kotlin/reporters/StaticHtmlReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -380,23 +380,24 @@ class StaticHtmlReporter : Reporter() {

ul {
reportTableModel.evaluatorIssues?.let { ruleViolations ->
val issues = ruleViolations.groupBy { it.severity }
val issues = ruleViolations.filterNot { it.isResolved }.groupBy { it.severity }
val errorCount = issues[Severity.ERROR].orEmpty().count()
val warningCount = issues[Severity.WARNING].orEmpty().count()
val hintCount = issues[Severity.HINT].orEmpty().count()

li {
a("#rule-violation-summary") {
+"Rule Violation Summary ($errorCount errors, $warningCount warnings, $hintCount hints)"
+("Rule Violation Summary ($errorCount errors, $warningCount warnings, $hintCount hints to " +
"resolve)")
}
}
}

if (reportTableModel.issueSummary.allIssues.isNotEmpty()) {
if (reportTableModel.issueSummary.rows.isNotEmpty()) {
li {
a("#issue-summary") {
with(reportTableModel.issueSummary) {
+"Issue Summary ($errorCount errors, $warningCount warnings, $hintCount hints)"
+"Issue Summary ($errorCount errors, $warningCount warnings, $hintCount hints to resolve)"
}
}
}
Expand All @@ -418,14 +419,14 @@ class StaticHtmlReporter : Reporter() {
}

private fun DIV.evaluatorTable(ruleViolations: List<ResolvableIssue>) {
val issues = ruleViolations.groupBy { it.severity }
val issues = ruleViolations.filterNot { it.isResolved }.groupBy { it.severity }
val errorCount = issues[Severity.ERROR].orEmpty().count()
val warningCount = issues[Severity.WARNING].orEmpty().count()
val hintCount = issues[Severity.HINT].orEmpty().count()

h2 {
id = "rule-violation-summary"
+"Rule Violation Summary ($errorCount errors, $warningCount warnings, $hintCount hints)"
+"Rule Violation Summary ($errorCount errors, $warningCount warnings, $hintCount hints to resolve)"
}

if (ruleViolations.isEmpty()) {
Expand Down Expand Up @@ -482,7 +483,7 @@ class StaticHtmlReporter : Reporter() {
h2 {
id = "issue-summary"
with(issueSummary) {
+"Issue Summary ($errorCount errors, $warningCount warnings, $hintCount hints)"
+"Issue Summary ($errorCount errors, $warningCount warnings, $hintCount hints to resolve)"
}
}

Expand Down

0 comments on commit 6236278

Please sign in to comment.