Skip to content

Commit 85d1b92

Browse files
authored
Merge pull request #872 from jenkinsci/sub-reports
Make reports a hierarchical data structure
2 parents 1122db1 + 19a0422 commit 85d1b92

214 files changed

Lines changed: 1622 additions & 65567 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v2.3.4
2121
- name: Set up JDK 11
22-
uses: actions/setup-java@v1
22+
uses: actions/setup-java@v2
2323
with:
24-
java-version: 11
24+
distribution: 'adopt'
25+
java-version: '11'
26+
check-latest: true
2527
- name: Cache local Maven repository
2628
uses: actions/cache@v2.1.4
2729
with:

doc/Custom-Plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import javax.annotation.Nonnull;
8787

8888
import org.kohsuke.stapler.DataBoundConstructor;
8989

90-
import io.jenkins.plugins.analysis.core.model.ReportScanningTool;
90+
import io.jenkins.plugins.analysis.core.model.AnalysisModelParser;
9191

9292
import hudson.Extension;
9393

plugin/pom.xml

Lines changed: 37 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -21,13 +22,13 @@
2122
<url>https://github.com/jenkinsci/warnings-ng-plugin</url>
2223

2324
<properties>
24-
<revision>8.10.2</revision>
25+
<revision>9.0.0</revision>
2526
<changelist>-SNAPSHOT</changelist>
2627

2728
<module.name>${project.groupId}.warnings.ng</module.name>
2829

29-
<analysis-model-api.version>9.8.1</analysis-model-api.version>
30-
<analysis-model-tests.version>9.8.1</analysis-model-tests.version>
30+
<analysis-model-api.version>10.0.0-rc412.b44250d40e97</analysis-model-api.version>
31+
<analysis-model-tests.version>10.0.0</analysis-model-tests.version>
3132

3233
<forensics-api-plugin.version>1.0.0</forensics-api-plugin.version>
3334
<plugin-util-api.version>2.1.0</plugin-util-api.version>
@@ -40,15 +41,11 @@
4041
<popper-api.version>1.16.1-2</popper-api.version>
4142
<error_prone_annotations.version>2.6.0</error_prone_annotations.version>
4243

43-
<commons.digester3.version>3.2</commons.digester3.version>
44-
4544
<eclipse-collections.version>9.2.0</eclipse-collections.version>
4645
<j2html.version>1.4.0</j2html.version>
4746

4847
<json.version>20210307</json.version>
4948

50-
<pmd.version>6.32.0</pmd.version>
51-
5249
<!-- Test Library Dependencies Versions -->
5350
<xmlunit.version>2.8.2</xmlunit.version>
5451
<jsoup.version>1.13.1</jsoup.version>
@@ -122,6 +119,11 @@
122119
<artifactId>error_prone_annotations</artifactId>
123120
<version>${error_prone_annotations.version}</version>
124121
</dependency>
122+
<dependency>
123+
<groupId>com.google.code.gson</groupId>
124+
<artifactId>gson</artifactId>
125+
<version>2.8.6</version>
126+
</dependency>
125127
</dependencies>
126128
</dependencyManagement>
127129

@@ -138,17 +140,6 @@
138140
<artifactId>eclipse-collections</artifactId>
139141
<version>${eclipse-collections.version}</version>
140142
</dependency>
141-
<dependency>
142-
<groupId>org.apache.commons</groupId>
143-
<artifactId>commons-digester3</artifactId>
144-
<version>${commons.digester3.version}</version>
145-
<exclusions>
146-
<exclusion>
147-
<artifactId>asm</artifactId>
148-
<groupId>asm</groupId>
149-
</exclusion>
150-
</exclusions>
151-
</dependency>
152143
<dependency>
153144
<groupId>com.j2html</groupId>
154145
<artifactId>j2html</artifactId>
@@ -165,58 +156,6 @@
165156
<version>${jsoup.version}</version>
166157
</dependency>
167158

168-
<!-- PMD Messages -->
169-
<dependency>
170-
<groupId>net.sourceforge.pmd</groupId>
171-
<artifactId>pmd-core</artifactId>
172-
<version>${pmd.version}</version>
173-
<exclusions>
174-
<exclusion>
175-
<groupId>com.ibm.icu</groupId>
176-
<artifactId>icu4j</artifactId>
177-
</exclusion>
178-
<exclusion>
179-
<groupId>net.sourceforge.saxon</groupId>
180-
<artifactId>saxon</artifactId>
181-
</exclusion>
182-
<exclusion>
183-
<groupId>org.ow2.asm</groupId>
184-
<artifactId>asm</artifactId>
185-
</exclusion>
186-
<exclusion>
187-
<groupId>commons-io</groupId>
188-
<artifactId>commons-io</artifactId>
189-
</exclusion>
190-
<exclusion>
191-
<groupId>org.apache.commons</groupId>
192-
<artifactId>commons-lang3</artifactId>
193-
</exclusion>
194-
</exclusions>
195-
</dependency>
196-
<dependency>
197-
<groupId>net.sourceforge.pmd</groupId>
198-
<artifactId>pmd-java</artifactId>
199-
<version>${pmd.version}</version>
200-
<exclusions>
201-
<exclusion>
202-
<groupId>net.sourceforge.saxon</groupId>
203-
<artifactId>saxon</artifactId>
204-
</exclusion>
205-
<exclusion>
206-
<groupId>org.ow2.asm</groupId>
207-
<artifactId>asm</artifactId>
208-
</exclusion>
209-
<exclusion>
210-
<groupId>commons-io</groupId>
211-
<artifactId>commons-io</artifactId>
212-
</exclusion>
213-
<exclusion>
214-
<groupId>org.apache.commons</groupId>
215-
<artifactId>commons-lang3</artifactId>
216-
</exclusion>
217-
</exclusions>
218-
</dependency>
219-
220159
<!-- Required Jenkins Plug-in Dependencies -->
221160
<dependency>
222161
<groupId>io.jenkins.plugins</groupId>
@@ -319,6 +258,13 @@
319258
<version>${token-macro.version}</version>
320259
<optional>true</optional>
321260
</dependency>
261+
<!-- ASM is required by token-macro but does not declare its dependency -->
262+
<dependency>
263+
<groupId>org.ow2.asm</groupId>
264+
<artifactId>asm</artifactId>
265+
<version>8.0.1</version>
266+
<scope>test</scope>
267+
</dependency>
322268
<dependency>
323269
<groupId>io.jenkins.plugins</groupId>
324270
<artifactId>forensics-api</artifactId>
@@ -364,6 +310,10 @@
364310
<type>test-jar</type>
365311
<scope>test</scope>
366312
<exclusions>
313+
<exclusion>
314+
<groupId>edu.hm.hafner</groupId>
315+
<artifactId>codingstyle</artifactId>
316+
</exclusion>
367317
<exclusion>
368318
<groupId>com.github.spotbugs</groupId>
369319
<artifactId>spotbugs-annotations</artifactId>
@@ -372,6 +322,18 @@
372322
<groupId>commons-io</groupId>
373323
<artifactId>commons-io</artifactId>
374324
</exclusion>
325+
<exclusion>
326+
<groupId>org.apache.commons</groupId>
327+
<artifactId>commons-lang3</artifactId>
328+
</exclusion>
329+
<exclusion>
330+
<groupId>jaxen</groupId>
331+
<artifactId>jaxen</artifactId>
332+
</exclusion>
333+
<exclusion>
334+
<artifactId>*</artifactId>
335+
<groupId>org.ow2.asm</groupId>
336+
</exclusion>
375337
</exclusions>
376338
</dependency>
377339
<dependency>
@@ -540,6 +502,10 @@
540502
<groupId>commons-beanutils</groupId>
541503
<artifactId>commons-beanutils</artifactId>
542504
</exclusion>
505+
<exclusion>
506+
<groupId>edu.hm.hafner</groupId>
507+
<artifactId>codingstyle</artifactId>
508+
</exclusion>
543509
</exclusions>
544510
</dependency>
545511

plugin/src/main/java/io/jenkins/plugins/analysis/core/charts/SeverityPieChart.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.jenkins.plugins.analysis.core.charts;
22

3-
import org.eclipse.collections.api.set.ImmutableSet;
4-
53
import edu.hm.hafner.analysis.Report;
64
import edu.hm.hafner.analysis.Severity;
75
import edu.hm.hafner.echarts.PieChartModel;
@@ -26,8 +24,7 @@ public class SeverityPieChart {
2624
public PieChartModel create(final Report report) {
2725
PieChartModel model = new PieChartModel(Messages.Severities_Name());
2826

29-
ImmutableSet<Severity> predefinedSeverities = Severity.getPredefinedValues();
30-
for (Severity severity : predefinedSeverities) {
27+
for (Severity severity : Severity.getPredefinedValues()) {
3128
int total = report.getSizeOf(severity);
3229
if (total > 0 || !severity.equals(Severity.ERROR)) {
3330
model.add(new PieData(LocalizedSeverity.getLocalizedString(severity), total),
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package io.jenkins.plugins.analysis.core.model;
2+
3+
import edu.hm.hafner.analysis.Issue;
4+
import edu.hm.hafner.analysis.IssueParser;
5+
import edu.hm.hafner.analysis.registry.ParserDescriptor;
6+
import edu.hm.hafner.analysis.registry.ParserDescriptor.Option;
7+
import edu.hm.hafner.analysis.registry.ParserRegistry;
8+
import edu.umd.cs.findbugs.annotations.NonNull;
9+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
10+
11+
/**
12+
* Describes a static analysis tool from the analysis-model library.
13+
*
14+
* @author Ullrich Hafner
15+
*/
16+
public abstract class AnalysisModelParser extends ReportScanningTool {
17+
private static final long serialVersionUID = 3510579055771471269L;
18+
19+
@Override
20+
public IssueParser createParser() {
21+
return getDescriptor().createParser(configureOptions());
22+
}
23+
24+
/**
25+
* Returns optional options to configure the parser - these options may customize the new parser instance (if
26+
* supported by the selected).
27+
*
28+
* @return the options to use
29+
*/
30+
protected Option[] configureOptions() {
31+
return new Option[0];
32+
}
33+
34+
@Override
35+
@SuppressFBWarnings("BC")
36+
public AnalysisModelParserDescriptor getDescriptor() {
37+
return (AnalysisModelParserDescriptor) super.getDescriptor();
38+
}
39+
40+
/** Descriptor for {@link AnalysisModelParser}. **/
41+
public abstract static class AnalysisModelParserDescriptor extends ReportScanningToolDescriptor {
42+
private static final ParserRegistry REGISTRY = new ParserRegistry();
43+
44+
private final RegistryIssueDescriptionProvider descriptionProvider;
45+
private final ParserDescriptor analysisModelDescriptor;
46+
47+
/**
48+
* Creates a new instance of {@link AnalysisModelParserDescriptor} with the given ID.
49+
*
50+
* @param id
51+
* the unique ID of the tool
52+
*/
53+
protected AnalysisModelParserDescriptor(final String id) {
54+
this(id, id);
55+
}
56+
57+
/**
58+
* Creates a new instance of {@link AnalysisModelParserDescriptor} with the given ID.
59+
*
60+
* @param id
61+
* the unique ID of the tool
62+
* @param descriptionId
63+
* the description ID of the tool in the analysis model module
64+
*/
65+
protected AnalysisModelParserDescriptor(final String id, final String descriptionId) {
66+
super(id);
67+
68+
analysisModelDescriptor = REGISTRY.get(descriptionId);
69+
descriptionProvider = new RegistryIssueDescriptionProvider(analysisModelDescriptor);
70+
}
71+
72+
/**
73+
* Returns a {@link StaticAnalysisLabelProvider} that will render all tool specific labels.
74+
*
75+
* @return a tool specific {@link StaticAnalysisLabelProvider}
76+
*/
77+
@Override
78+
public StaticAnalysisLabelProvider getLabelProvider() {
79+
return new StaticAnalysisLabelProvider(getId(), getDisplayName(), descriptionProvider);
80+
}
81+
82+
/**
83+
* Returns a description provider to obtain detailed issue descriptions.
84+
*
85+
* @return a description provider
86+
*/
87+
protected RegistryIssueDescriptionProvider getDescriptionProvider() {
88+
return descriptionProvider;
89+
}
90+
91+
/**
92+
* Returns a new parser to scan a log file and return the issues reported in such a file.
93+
*
94+
* @param options
95+
* options to configure the parser - may customize the new parser instance (if supported by the selected
96+
* tool)
97+
*
98+
* @return the parser to use
99+
*/
100+
public IssueParser createParser(final Option... options) {
101+
return analysisModelDescriptor.createParser(options);
102+
}
103+
104+
@Override
105+
public String getPattern() {
106+
return analysisModelDescriptor.getPattern();
107+
}
108+
109+
@Override
110+
public String getHelp() {
111+
return analysisModelDescriptor.getHelp();
112+
}
113+
114+
@Override
115+
public String getUrl() {
116+
return analysisModelDescriptor.getUrl();
117+
}
118+
119+
@NonNull
120+
@Override
121+
public final String getDisplayName() {
122+
return analysisModelDescriptor.getName();
123+
}
124+
}
125+
126+
/**
127+
* Extracts a description from the associated {@link ParserDescriptor}.
128+
*/
129+
private static class RegistryIssueDescriptionProvider implements DescriptionProvider {
130+
private final ParserDescriptor parserDescriptor;
131+
132+
RegistryIssueDescriptionProvider(final ParserDescriptor parserDescriptor) {
133+
this.parserDescriptor = parserDescriptor;
134+
}
135+
136+
@Override
137+
public String getDescription(final Issue issue) {
138+
return parserDescriptor.getDescription(issue);
139+
}
140+
}
141+
}

plugin/src/main/java/io/jenkins/plugins/analysis/core/model/AnalysisResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ protected AnalysisResult(final Run<?, ?> owner, final String id, final DeltaRepo
238238
Report fixedIssues = report.getFixedIssues();
239239
fixedIssuesReference = new WeakReference<>(fixedIssues);
240240

241-
List<String> aggregatedMessages = new ArrayList<>(allIssues.getInfoMessages().castToList());
241+
List<String> aggregatedMessages = new ArrayList<>(allIssues.getInfoMessages());
242242

243243
messages = new ArrayList<>(aggregatedMessages);
244-
errors = new ArrayList<>(allIssues.getErrorMessages().castToList());
244+
errors = new ArrayList<>(allIssues.getErrorMessages());
245245

246246
this.qualityGateStatus = qualityGateStatus;
247247

plugin/src/main/java/io/jenkins/plugins/analysis/core/model/DescriptionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @author Ullrich Hafner
99
*/
10+
@FunctionalInterface
1011
public interface DescriptionProvider {
1112
/**
1213
* Returns a detailed description of the specified issue.

0 commit comments

Comments
 (0)