diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/charts/ModifiedCodePieChart.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/charts/ModifiedCodePieChart.java index f690046837..1d63ca4215 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/charts/ModifiedCodePieChart.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/charts/ModifiedCodePieChart.java @@ -24,8 +24,9 @@ public PieChartModel create(final Report issues) { PieChartModel model = new PieChartModel(Messages.NewVersusFixed_Name()); var totals = issues.size(); - model.add(new PieData(Messages.Modified_Code_Warnings_Short(), totals), JenkinsPalette.RED.normal()); - model.add(new PieData(Messages.Unchanged_Code_Warnings_Short(), totals), JenkinsPalette.YELLOW.normal()); + var modified = issues.getInModifiedCode().size(); + model.add(new PieData(Messages.Modified_Code_Warnings_Short(), modified), JenkinsPalette.RED.normal()); + model.add(new PieData(Messages.Unchanged_Code_Warnings_Short(), totals - modified), JenkinsPalette.YELLOW.normal()); return model; } diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/DetailFactory.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/DetailFactory.java index 30ff9a00b8..322f905cf8 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/DetailFactory.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/DetailFactory.java @@ -151,7 +151,7 @@ private Marker asMarker(final Issue issue, final String description, final Strin .withColumnEnd(issue.getColumnEnd()).build(); } - @SuppressWarnings({"checkstyle:ParameterNumber", "PMD.CyclomaticComplexity"}) + @SuppressWarnings({"checkstyle:ParameterNumber", "PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) @SuppressFBWarnings("IMPROPER_UNICODE") private Object createNewDetailView(final String link, final Run owner, final AnalysisResult result, final Report allIssues, final Report newIssues, final Report outstandingIssues, final Report fixedIssues, @@ -167,6 +167,11 @@ private Object createNewDetailView(final String link, final Run owner, fin filterModified(outstandingIssues), EMPTY, Messages.Modified_Warnings_Header(), url, labelProvider, sourceEncoding); } + if ("unchanged".equalsIgnoreCase(link)) { + return new IssuesDetail(owner, result, filterUnchanged(allIssues), filterUnchanged(newIssues), + filterUnchanged(outstandingIssues), EMPTY, + Messages.Modified_Warnings_Header(), url, labelProvider, sourceEncoding); + } if ("fixed".equalsIgnoreCase(link)) { return new FixedWarningsDetail(owner, result, fixedIssues, url, labelProvider, sourceEncoding); } @@ -200,6 +205,10 @@ private Report filterModified(final Report report) { return report.filter(Issue::isPartOfModifiedCode); } + private Report filterUnchanged(final Report report) { + return report.filter(Predicate.not(Issue::isPartOfModifiedCode)); + } + private Predicate createPropertyFilter(final String plainLink, final String property) { return issue -> plainLink.equals(String.valueOf( Issue.getPropertyValueAsString(issue, property).hashCode())); diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java index 0face0f6b9..f9f9b89644 100644 --- a/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java +++ b/plugin/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java @@ -407,6 +407,15 @@ private AnalysisHistory createHistory() { return new AnalysisHistory(owner, new ByIdResultSelector(result.getId())); } + /** + * Returns whether there are any issues in the associated static analysis run that are part of modified code. + * + * @return {@code true} if there are issues in modified code, {@code false} otherwise + */ + public boolean hasIssuesInModifiedCode() { + return result.getTotals().getTotalModifiedSize() > 0; + } + /** * Returns all issues of the associated static analysis run. * diff --git a/plugin/src/main/resources/io/jenkins/plugins/analysis/core/model/IssuesDetail/filled.jelly b/plugin/src/main/resources/io/jenkins/plugins/analysis/core/model/IssuesDetail/filled.jelly index 9b92999572..7f71ecdb2d 100644 --- a/plugin/src/main/resources/io/jenkins/plugins/analysis/core/model/IssuesDetail/filled.jelly +++ b/plugin/src/main/resources/io/jenkins/plugins/analysis/core/model/IssuesDetail/filled.jelly @@ -14,6 +14,11 @@ + + +