Skip to content

Commit

Permalink
Improve layout of Markdown.
Browse files Browse the repository at this point in the history
- Simplify warnings message.
- Use the configured icon if set.
  • Loading branch information
uhafner committed May 8, 2024
1 parent ede7795 commit 4c6e8ab
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/main/java/edu/hm/hafner/grading/AnalysisMarkdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private int sum(final AnalysisScore score, final Function<AnalysisScore, Integer

protected String extractSeverities(final AnalysisScore score) {
if (score.getReport().isEmpty()) {
return "No warnings found";
return "No warnings";
}
else {
return String.format("%d warning%s found (%d error%s, %d high, %d normal, %d low)",
return String.format("%d warning%s (%d error%s, %d high, %d normal, %d low)",
score.getTotalSize(), AnalysisScore.plural(score.getTotalSize()),
score.getErrorSize(), AnalysisScore.plural(score.getErrorSize()),
score.getHighSeveritySize(),
Expand Down Expand Up @@ -121,7 +121,7 @@ private String getIconAndName(final AnalysisScore analysisScore) {
private String extractParserIcon(final AnalysisScore analysisScore) {
var descriptor = REGISTRY.get(analysisScore.getId());
if (descriptor.getIconUrl().isEmpty()) {
return ":exclamation:";
return getIcon(analysisScore);
}
else {
return "<img src=\"%s\" alt=\"%s\" height=\"%d\" width=\"%d\">"
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/hm/hafner/grading/AnalysisScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public int getTotalSize() {
@Override
protected String createSummary() {
if (getReport().isEmpty()) {
return "No warnings found";
return "No warnings";
}
else {
return String.format("%d warning%s found (%d error%s, %d high, %d normal, %d low)",
return String.format("%d warning%s (%d error%s, %d high, %d normal, %d low)",
getTotalSize(), plural(getTotalSize()),
getErrorSize(), plural(getErrorSize()),
getHighSeveritySize(), getNormalSeveritySize(), getLowSeveritySize());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/hm/hafner/grading/TestMarkdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ protected String createSummary(final TestScore score) {
- :microscope: &nbsp; Mutation Coverage: 93% mutations killed
- ☑️ 99% Test strength
---
- :warning: &nbsp; Style:: No warnings found
- :bug: &nbsp; Bugs: No warnings found
- :warning: &nbsp; Style:: No warnings
- :bug: &nbsp; Bugs: No warnings
<br/>
Created by [Quality Monitor](https://github.com/uhafner/quality-monitor/releases/tag/v1.6.0) v1.6.0 (#85eae94). More details are shown in the [GitHub Checks Result](https://github.com/jenkinsci/coverage-model/runs/23474192891).
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/edu/hm/hafner/grading/AnalysisMarkdownTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void shouldShowMaximumScore() {
.contains(IMPACT_CONFIGURATION);
assertThat(analysisMarkdown.createSummary(score))
.contains("CheckStyle - 100 of 100")
.contains("No warnings found");
.contains("No warnings");
}

@Test
Expand Down Expand Up @@ -87,7 +87,7 @@ void shouldShowScoreWithOneResult() {
var analysisMarkdown = new AnalysisMarkdown();

assertThat(analysisMarkdown.createSummary(score)).contains(
"CS - 70 of 100: 10 warnings found (1 error, 2 high, 3 normal, 4 low)");
"CS - 70 of 100: 10 warnings (1 error, 2 high, 3 normal, 4 low)");
assertThat(analysisMarkdown.createDetails(score))
.contains("TopLevel Warnings - 70 of 100")
.contains("|CS|1|1|2|3|4|10|-30")
Expand Down Expand Up @@ -126,8 +126,8 @@ void shouldShowScoreWithTwoSubResults() {

assertThat(analysisMarkdown.createSummary(score))
.contains(
"CheckStyle - 70 of 100: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs - 80 of 100: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)");
"CheckStyle - 70 of 100: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs - 80 of 100: 10 warnings (4 errors, 3 high, 2 normal, 1 low)");
assertThat(analysisMarkdown.createDetails(score))
.contains("CheckStyle - 50 of 100",
"|CheckStyle|1|1|2|3|4|10|-30",
Expand Down Expand Up @@ -162,8 +162,8 @@ void shouldShowNoImpactsWithTwoSubResults() {
var analysisMarkdown = new AnalysisMarkdown();

assertThat(analysisMarkdown.createSummary(score))
.contains("CheckStyle: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)");
.contains("CheckStyle: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs: 10 warnings (4 errors, 3 high, 2 normal, 1 low)");
assertThat(analysisMarkdown.createDetails(score))
.contains("CheckStyle",
"|CheckStyle|1|1|2|3|4|10",
Expand Down Expand Up @@ -217,10 +217,10 @@ void shouldShowScoreWithTwoResults() {
":moneybag:|:heavy_minus_sign:|*1*|*2*|*3*|*4*|:heavy_minus_sign:|:heavy_minus_sign:",
":moneybag:|:heavy_minus_sign:|*-11*|*-12*|*-13*|*-14*|:heavy_minus_sign:|:heavy_minus_sign:");
assertThat(analysisMarkdown.createSummary(score))
.contains("CheckStyle 1 - 30 of 100: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"CheckStyle 2 - 30 of 100: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs 1 - 0 of 100: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)",
"SpotBugs 2 - 0 of 100: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)")
.contains("CheckStyle 1 - 30 of 100: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"CheckStyle 2 - 30 of 100: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs 1 - 0 of 100: 10 warnings (4 errors, 3 high, 2 normal, 1 low)",
"SpotBugs 2 - 0 of 100: 10 warnings (4 errors, 3 high, 2 normal, 1 low)")
.doesNotContain("Total");
}

Expand Down
16 changes: 8 additions & 8 deletions src/test/java/edu/hm/hafner/grading/GradingReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ void shouldCreateAllGradingResults() {
"Line Coverage - 60 of 100", "80% (20 missed lines)",
"Branch Coverage - 20 of 100", "60% (40 missed branches)",
"Mutation Coverage - 20 of 100: 60% (40 survived mutations)",
"Checkstyle - 30 of 100: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs - 0 of 100: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)");
"Checkstyle - 30 of 100: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs - 0 of 100: 10 warnings (4 errors, 3 high, 2 normal, 1 low)");
assertThat(results.getTextSummary(score)).isEqualTo(
"Autograding score - 167 of 500 (33%)");
assertThat(results.getMarkdownDetails(score)).contains(
Expand All @@ -142,8 +142,8 @@ void shouldCreateAllQualityResults() {
"Line Coverage: 80% (20 missed lines)",
"Branch Coverage: 60% (40 missed branches)",
"Mutation Coverage: 60% (40 survived mutations)",
"Checkstyle: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)");
"Checkstyle: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs: 10 warnings (4 errors, 3 high, 2 normal, 1 low)");
assertThat(results.getTextSummary(score)).isEqualTo(
"Autograding score");
assertThat(results.getMarkdownDetails(score)).contains(
Expand Down Expand Up @@ -198,8 +198,8 @@ void shouldSkipScores() {
aggregation.gradeAnalysis((tool, log) -> AnalysisMarkdownTest.createTwoReports(tool));
assertThat(logger.getInfoMessages()).contains(
"Processing 2 static analysis configuration(s)",
"=> Style: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"=> Bugs: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)");
"=> Style: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"=> Bugs: 10 warnings (4 errors, 3 high, 2 normal, 1 low)");

aggregation.gradeTests((tool, log) -> TestMarkdownTest.createTwoReports(tool));
assertThat(logger.getInfoMessages()).contains(
Expand Down Expand Up @@ -229,8 +229,8 @@ void shouldSkipScores() {
"Line Coverage: 80% (20 missed lines)",
"Branch Coverage: 60% (40 missed branches)",
"Mutation Coverage: 60% (40 survived mutations)",
"Checkstyle: 10 warnings found (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs: 10 warnings found (4 errors, 3 high, 2 normal, 1 low)");
"Checkstyle: 10 warnings (1 error, 2 high, 3 normal, 4 low)",
"SpotBugs: 10 warnings (4 errors, 3 high, 2 normal, 1 low)");
assertThat(results.getTextSummary(aggregation)).isEqualTo(
"Autograding score");
assertThat(results.getTextSummary(aggregation, "Quality Summary")).isEqualTo(
Expand Down

0 comments on commit 4c6e8ab

Please sign in to comment.