Skip to content

Commit

Permalink
Merge pull request #872 from jenkinsci/sub-reports
Browse files Browse the repository at this point in the history
 Make reports a hierarchical data structure
  • Loading branch information
uhafner authored Apr 11, 2021
2 parents 1122db1 + 19a0422 commit 85d1b92
Show file tree
Hide file tree
Showing 214 changed files with 1,622 additions and 65,567 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ jobs:
steps:
- uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'
java-version: '11'
check-latest: true
- name: Cache local Maven repository
uses: actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion doc/Custom-Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import javax.annotation.Nonnull;

import org.kohsuke.stapler.DataBoundConstructor;

import io.jenkins.plugins.analysis.core.model.ReportScanningTool;
import io.jenkins.plugins.analysis.core.model.AnalysisModelParser;

import hudson.Extension;

Expand Down
108 changes: 37 additions & 71 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<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">
<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">
<modelVersion>4.0.0</modelVersion>

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

<properties>
<revision>8.10.2</revision>
<revision>9.0.0</revision>
<changelist>-SNAPSHOT</changelist>

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

<analysis-model-api.version>9.8.1</analysis-model-api.version>
<analysis-model-tests.version>9.8.1</analysis-model-tests.version>
<analysis-model-api.version>10.0.0-rc412.b44250d40e97</analysis-model-api.version>
<analysis-model-tests.version>10.0.0</analysis-model-tests.version>

<forensics-api-plugin.version>1.0.0</forensics-api-plugin.version>
<plugin-util-api.version>2.1.0</plugin-util-api.version>
Expand All @@ -40,15 +41,11 @@
<popper-api.version>1.16.1-2</popper-api.version>
<error_prone_annotations.version>2.6.0</error_prone_annotations.version>

<commons.digester3.version>3.2</commons.digester3.version>

<eclipse-collections.version>9.2.0</eclipse-collections.version>
<j2html.version>1.4.0</j2html.version>

<json.version>20210307</json.version>

<pmd.version>6.32.0</pmd.version>

<!-- Test Library Dependencies Versions -->
<xmlunit.version>2.8.2</xmlunit.version>
<jsoup.version>1.13.1</jsoup.version>
Expand Down Expand Up @@ -122,6 +119,11 @@
<artifactId>error_prone_annotations</artifactId>
<version>${error_prone_annotations.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -138,17 +140,6 @@
<artifactId>eclipse-collections</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>${commons.digester3.version}</version>
<exclusions>
<exclusion>
<artifactId>asm</artifactId>
<groupId>asm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.j2html</groupId>
<artifactId>j2html</artifactId>
Expand All @@ -165,58 +156,6 @@
<version>${jsoup.version}</version>
</dependency>

<!-- PMD Messages -->
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${pmd.version}</version>
<exclusions>
<exclusion>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
</exclusion>
<exclusion>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmd.version}</version>
<exclusions>
<exclusion>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Required Jenkins Plug-in Dependencies -->
<dependency>
<groupId>io.jenkins.plugins</groupId>
Expand Down Expand Up @@ -319,6 +258,13 @@
<version>${token-macro.version}</version>
<optional>true</optional>
</dependency>
<!-- ASM is required by token-macro but does not declare its dependency -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>8.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>forensics-api</artifactId>
Expand Down Expand Up @@ -364,6 +310,10 @@
<type>test-jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
Expand All @@ -372,6 +322,18 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.ow2.asm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -540,6 +502,10 @@
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</exclusion>
<exclusion>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.jenkins.plugins.analysis.core.charts;

import org.eclipse.collections.api.set.ImmutableSet;

import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.echarts.PieChartModel;
Expand All @@ -26,8 +24,7 @@ public class SeverityPieChart {
public PieChartModel create(final Report report) {
PieChartModel model = new PieChartModel(Messages.Severities_Name());

ImmutableSet<Severity> predefinedSeverities = Severity.getPredefinedValues();
for (Severity severity : predefinedSeverities) {
for (Severity severity : Severity.getPredefinedValues()) {
int total = report.getSizeOf(severity);
if (total > 0 || !severity.equals(Severity.ERROR)) {
model.add(new PieData(LocalizedSeverity.getLocalizedString(severity), total),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package io.jenkins.plugins.analysis.core.model;

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueParser;
import edu.hm.hafner.analysis.registry.ParserDescriptor;
import edu.hm.hafner.analysis.registry.ParserDescriptor.Option;
import edu.hm.hafner.analysis.registry.ParserRegistry;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Describes a static analysis tool from the analysis-model library.
*
* @author Ullrich Hafner
*/
public abstract class AnalysisModelParser extends ReportScanningTool {
private static final long serialVersionUID = 3510579055771471269L;

@Override
public IssueParser createParser() {
return getDescriptor().createParser(configureOptions());
}

/**
* Returns optional options to configure the parser - these options may customize the new parser instance (if
* supported by the selected).
*
* @return the options to use
*/
protected Option[] configureOptions() {
return new Option[0];
}

@Override
@SuppressFBWarnings("BC")
public AnalysisModelParserDescriptor getDescriptor() {
return (AnalysisModelParserDescriptor) super.getDescriptor();
}

/** Descriptor for {@link AnalysisModelParser}. **/
public abstract static class AnalysisModelParserDescriptor extends ReportScanningToolDescriptor {
private static final ParserRegistry REGISTRY = new ParserRegistry();

private final RegistryIssueDescriptionProvider descriptionProvider;
private final ParserDescriptor analysisModelDescriptor;

/**
* Creates a new instance of {@link AnalysisModelParserDescriptor} with the given ID.
*
* @param id
* the unique ID of the tool
*/
protected AnalysisModelParserDescriptor(final String id) {
this(id, id);
}

/**
* Creates a new instance of {@link AnalysisModelParserDescriptor} with the given ID.
*
* @param id
* the unique ID of the tool
* @param descriptionId
* the description ID of the tool in the analysis model module
*/
protected AnalysisModelParserDescriptor(final String id, final String descriptionId) {
super(id);

analysisModelDescriptor = REGISTRY.get(descriptionId);
descriptionProvider = new RegistryIssueDescriptionProvider(analysisModelDescriptor);
}

/**
* Returns a {@link StaticAnalysisLabelProvider} that will render all tool specific labels.
*
* @return a tool specific {@link StaticAnalysisLabelProvider}
*/
@Override
public StaticAnalysisLabelProvider getLabelProvider() {
return new StaticAnalysisLabelProvider(getId(), getDisplayName(), descriptionProvider);
}

/**
* Returns a description provider to obtain detailed issue descriptions.
*
* @return a description provider
*/
protected RegistryIssueDescriptionProvider getDescriptionProvider() {
return descriptionProvider;
}

/**
* Returns a new parser to scan a log file and return the issues reported in such a file.
*
* @param options
* options to configure the parser - may customize the new parser instance (if supported by the selected
* tool)
*
* @return the parser to use
*/
public IssueParser createParser(final Option... options) {
return analysisModelDescriptor.createParser(options);
}

@Override
public String getPattern() {
return analysisModelDescriptor.getPattern();
}

@Override
public String getHelp() {
return analysisModelDescriptor.getHelp();
}

@Override
public String getUrl() {
return analysisModelDescriptor.getUrl();
}

@NonNull
@Override
public final String getDisplayName() {
return analysisModelDescriptor.getName();
}
}

/**
* Extracts a description from the associated {@link ParserDescriptor}.
*/
private static class RegistryIssueDescriptionProvider implements DescriptionProvider {
private final ParserDescriptor parserDescriptor;

RegistryIssueDescriptionProvider(final ParserDescriptor parserDescriptor) {
this.parserDescriptor = parserDescriptor;
}

@Override
public String getDescription(final Issue issue) {
return parserDescriptor.getDescription(issue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ protected AnalysisResult(final Run<?, ?> owner, final String id, final DeltaRepo
Report fixedIssues = report.getFixedIssues();
fixedIssuesReference = new WeakReference<>(fixedIssues);

List<String> aggregatedMessages = new ArrayList<>(allIssues.getInfoMessages().castToList());
List<String> aggregatedMessages = new ArrayList<>(allIssues.getInfoMessages());

messages = new ArrayList<>(aggregatedMessages);
errors = new ArrayList<>(allIssues.getErrorMessages().castToList());
errors = new ArrayList<>(allIssues.getErrorMessages());

this.qualityGateStatus = qualityGateStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Ullrich Hafner
*/
@FunctionalInterface
public interface DescriptionProvider {
/**
* Returns a detailed description of the specified issue.
Expand Down
Loading

0 comments on commit 85d1b92

Please sign in to comment.