From 6b719bc89b9c55a097b0f4c48453d031430bac09 Mon Sep 17 00:00:00 2001
From: per1234 <accounts@perglass.com>
Date: Mon, 19 Jul 2021 11:05:59 -0700
Subject: [PATCH] Simplify summary output

This less verbose approach to the project and projects linting summary output provides the same amount of information in
a more approachable format.
---
 internal/result/result.go      | 20 +++++++++++++++++---
 internal/result/result_test.go | 12 ++++++++++--
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/internal/result/result.go b/internal/result/result.go
index 2a3b87c7..f86303d3 100644
--- a/internal/result/result.go
+++ b/internal/result/result.go
@@ -194,8 +194,15 @@ func (results Type) ProjectSummaryText(lintedProject project.Type) string {
 		panic(fmt.Sprintf("Unable to find report for %v when generating report summary text", lintedProject.Path))
 	}
 
-	projectSummaryReport := results.Projects[projectReportIndex].Summary
-	return fmt.Sprintf("Finished linting project. Results:\nWarning count: %v\nError count: %v\nRules passed: %v", projectSummaryReport.WarningCount, projectSummaryReport.ErrorCount, projectSummaryReport.Pass)
+	projectSummaryReport := "Linter results for project: "
+	projectSummaryData := results.Projects[projectReportIndex].Summary
+	if projectSummaryData.ErrorCount == 0 && projectSummaryData.WarningCount == 0 {
+		projectSummaryReport += "no errors or warnings"
+	} else {
+		projectSummaryReport += fmt.Sprintf("%v ERRORS, %v WARNINGS", projectSummaryData.ErrorCount, projectSummaryData.WarningCount)
+	}
+
+	return projectSummaryReport
 }
 
 // AddSummary summarizes the rule results for all projects and adds it to the report.
@@ -220,7 +227,14 @@ func (results *Type) AddSummary() {
 
 // SummaryText returns a text summary of the cumulative rule results.
 func (results Type) SummaryText() string {
-	return fmt.Sprintf("Finished linting projects. Results:\nWarning count: %v\nError count: %v\nRules passed: %v", results.Summary.WarningCount, results.Summary.ErrorCount, results.Summary.Pass)
+	summaryReport := "Linter results for projects: "
+	if results.Summary.ErrorCount == 0 && results.Summary.WarningCount == 0 {
+		summaryReport += "no errors or warnings"
+	} else {
+		summaryReport += fmt.Sprintf("%v ERRORS, %v WARNINGS", results.Summary.ErrorCount, results.Summary.WarningCount)
+	}
+
+	return summaryReport
 }
 
 // JSONReport returns a JSON formatted report of rules on all projects in string encoding.
diff --git a/internal/result/result_test.go b/internal/result/result_test.go
index e79c4625..2a59a91c 100644
--- a/internal/result/result_test.go
+++ b/internal/result/result_test.go
@@ -207,7 +207,11 @@ func TestAddProjectSummary(t *testing.T) {
 		assert.Equal(t, testTable.expectedPass, results.Projects[0].Summary.Pass)
 		assert.Equal(t, testTable.expectedWarningCount, results.Projects[0].Summary.WarningCount)
 		assert.Equal(t, testTable.expectedErrorCount, results.Projects[0].Summary.ErrorCount)
-		assert.Equal(t, fmt.Sprintf("Finished linting project. Results:\nWarning count: %v\nError count: %v\nRules passed: %v", testTable.expectedWarningCount, testTable.expectedErrorCount, testTable.expectedPass), results.ProjectSummaryText(lintedProject))
+		if testTable.expectedErrorCount == 0 && testTable.expectedWarningCount == 0 {
+			assert.Equal(t, "Linter results for project: no errors or warnings", results.ProjectSummaryText(lintedProject))
+		} else {
+			assert.Equal(t, fmt.Sprintf("Linter results for project: %v ERRORS, %v WARNINGS", testTable.expectedErrorCount, testTable.expectedWarningCount), results.ProjectSummaryText(lintedProject))
+		}
 	}
 }
 
@@ -290,7 +294,11 @@ func TestAddSummary(t *testing.T) {
 		assert.Equal(t, testTable.expectedPass, results.Passed())
 		assert.Equal(t, testTable.expectedWarningCount, results.Summary.WarningCount)
 		assert.Equal(t, testTable.expectedErrorCount, results.Summary.ErrorCount)
-		assert.Equal(t, fmt.Sprintf("Finished linting projects. Results:\nWarning count: %v\nError count: %v\nRules passed: %v", testTable.expectedWarningCount, testTable.expectedErrorCount, testTable.expectedPass), results.SummaryText())
+		if testTable.expectedErrorCount == 0 && testTable.expectedWarningCount == 0 {
+			assert.Equal(t, "Linter results for projects: no errors or warnings", results.SummaryText())
+		} else {
+			assert.Equal(t, fmt.Sprintf("Linter results for projects: %v ERRORS, %v WARNINGS", testTable.expectedErrorCount, testTable.expectedWarningCount), results.SummaryText())
+		}
 	}
 }