Skip to content

Commit

Permalink
Do not show an icon in checks report when the coverage did not change.
Browse files Browse the repository at this point in the history
Fixes #662
  • Loading branch information
uhafner committed May 8, 2023
1 parent e486bea commit 2858a7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CoverageChecksPublisher {
private static final int TITLE_HEADER_LEVEL = 4;
private static final char NEW_LINE = '\n';
private static final String COLUMN = "|";
private static final String GAP = " ";

private final CoverageBuildAction action;
private final Node rootNode;
Expand Down Expand Up @@ -434,29 +435,29 @@ private String formatText(final TextFormat format, final String text) {
}

private String getTrendIcon(final String trend) {
if (!StringUtils.containsAny(trend, "123456789") || trend.startsWith("n/a")) {

Check warning on line 438 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 438 is only partially covered, one branch is missing
return StringUtils.EMPTY;
}
if (trend.startsWith("+")) {
return " " + Icon.ARROW_UP.markdown;
return GAP + Icon.ARROW_UP.markdown;
}
else if (trend.startsWith("-")) {

Check warning on line 444 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 444 is only partially covered, one branch is missing
return " " + Icon.ARROW_DOWN.markdown;
}
else if (trend.startsWith("n/a")) {
return StringUtils.EMPTY;
return GAP + Icon.ARROW_DOWN.markdown;
}
return " " + Icon.ARROW_RIGHT.markdown;
return GAP + Icon.ARROW_RIGHT.markdown;

Check warning on line 447 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 447 is not covered by tests

Check warning on line 447 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageChecksPublisher.java#L447

Added line #L447 was not covered by tests
}

private String getBulletListItem(final int level, final String text) {
int whitespaces = (level - 1) * TITLE_HEADER_LEVEL;
return String.join("", Collections.nCopies(whitespaces, " ")) + "* " + text + "\n";
return String.join("", Collections.nCopies(whitespaces, GAP)) + "* " + text + "\n";
}

private String getUrlText(final String text, final String url) {
return String.format("[%s](%s)", text, url);
}

private String getSectionHeader(final int level, final String text) {
return String.join("", Collections.nCopies(level, "#")) + " " + text + "\n\n";
return String.join("", Collections.nCopies(level, "#")) + GAP + text + "\n\n";
}

private ChecksConclusion getCheckConclusion(final QualityGateStatus status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private CoverageBuildAction createCoverageBuildAction(final Node result) {

return new CoverageBuildAction(run, COVERAGE_ID, REPORT_NAME, StringUtils.EMPTY, result,
new QualityGateResult(), null, "refId",
new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF, Metric.MODULE, Fraction.ONE_FIFTH)),
new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF, Metric.MODULE, Fraction.ZERO)),
List.of(testCoverage), new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF)), List.of(testCoverage),
new TreeMap<>(Map.of(Metric.LINE, Fraction.ONE_HALF)), List.of(testCoverage), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
||Module Coverage|Package Coverage|File Coverage|Class Coverage|Method Coverage|Line Coverage|Branch Coverage|Instruction Coverage
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:
:feet: **Overall project**|100.00% (1/1)|100.00% (4/4)|70.00% (7/10)|83.33% (15/18)|95.10% (97/102)|91.02% (294/323)|93.97% (109/116)|93.33% (1260/1350)
:chart_with_upwards_trend: **Overall project (difference to reference job)**|+20.00% :arrow_up:|n/a|n/a|n/a|n/a|+50.00% :arrow_up:|n/a|n/a
:chart_with_upwards_trend: **Overall project (difference to reference job)**|+0.00%|n/a|n/a|n/a|n/a|+50.00% :arrow_up:|n/a|n/a
:feet: **Modified files**|n/a|n/a|n/a|n/a|n/a|50.00% (1/2)|n/a|n/a
:chart_with_upwards_trend: **Modified files (difference to overall project)**|n/a|n/a|n/a|n/a|n/a|+50.00% :arrow_up:|n/a|n/a
:feet: **Modified code lines**|n/a|n/a|n/a|n/a|n/a|50.00% (1/2)|n/a|n/a
Expand Down

0 comments on commit 2858a7e

Please sign in to comment.