Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

13.0.0 #1928

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

13.0.0 #1928

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>9.0.0</version>
<version>10.2.0</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -38,30 +38,28 @@
<scm>
<connection>scm:git:https://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<tag>v11.10.0</tag>
<tag>HEAD</tag>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
</scm>

<properties>
<revision>11.13.0</revision>
<revision>12.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<module.name>${project.groupId}.warnings.ng</module.name>

<analysis-model-api.version>12.9.1</analysis-model-api.version>
<analysis-model-tests.version>${analysis-model-api.version}</analysis-model-tests.version>
<analysis-model-api.version>13.0.0-rc852.f04104a_881e9</analysis-model-api.version>
<analysis-model-tests.version>13.0.0-rc5991.66662b_93493c</analysis-model-tests.version>
<pull-request-monitoring.version>335.v525cd64ec76b_</pull-request-monitoring.version>

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

<!-- Test Library Dependencies Versions -->
<xmlunit.version>2.10.0</xmlunit.version>
<jsoup.version>1.18.1</jsoup.version>
<jsoup.version>1.18.3</jsoup.version>
<jmh.version>1.37</jmh.version>
<testcontainers.version>1.20.3</testcontainers.version>

<!-- Jenkins Plug-in Dependencies Versions -->
<git-forensics.version>2.2.1</git-forensics.version>

<flexible-publish.version>0.15.2</flexible-publish.version>
<form-element-path.version>1.11</form-element-path.version>

Expand Down Expand Up @@ -99,7 +97,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>plugin-util-api</artifactId>
<version>5.1.0</version>
<version>6.0.0-rc1031.7a_4203d33c1f</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
Expand Down Expand Up @@ -224,7 +222,6 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>git-forensics</artifactId>
<version>${git-forensics.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -305,7 +302,7 @@
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>plugin-util-api</artifactId>
<version>5.1.0</version>
<version>6.0.0-rc1031.7a_4203d33c1f</version>
<classifier>tests</classifier>
<scope>test</scope>
<exclusions>
Expand Down Expand Up @@ -578,6 +575,7 @@
<excludes combine.children="append">
<exclude>.*Thresholds</exclude>
<exclude>.*Test.*</exclude>
<exclude>.*Benchmark.*</exclude>
<exclude>.*TaskScanner.*</exclude>
</excludes>
<entryPointClassPackage>io.jenkins.plugins.analysis.core.assertions</entryPointClassPackage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IssuesTotalColumn() {
}

/**
* Called after de-serialization to retain backward compatibility..
* Called after deserialization to retain backward compatibility..
*
* @return this
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ public class DeltaReport {
public DeltaReport(final Report report, final int currentBuildNumber) {
allIssues = report;
outstandingIssues = report;
referenceIssues = EMPTY_REPORT;
newIssues = EMPTY_REPORT;
fixedIssues = EMPTY_REPORT;

var empty = report.copyEmptyInstance();
referenceIssues = empty;
newIssues = empty;
fixedIssues = empty;

referenceBuildId = StringUtils.EMPTY;

report.logInfo("No valid reference build found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public boolean canDisplayFile(final Issue issue) {

/**
* Returns the URL to the results of the same type of issues (i.e. same ID) in the reference build.
*
* <p>
* If no reference build is found, then an empty string is returned.
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class IconLabelProvider extends StaticAnalysisLabelProvider {
* the name of the tool
*/
public IconLabelProvider(final String id, final String name) {
this(id, name, EMPTY_DESCRIPTION, id);
this(id, name, EMPTY_DESCRIPTION);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public IssueReportScanner(final String filePattern, final String encoding,
@Override
protected Optional<Report> processFile(final Path file, final Charset charset, final FilteredLog log) {
try {
Report fileReport = parser.parseFile(new FileReaderFactory(file, charset));
Report fileReport = parser.parse(new FileReaderFactory(file, charset));

log.logInfo("Successfully parsed file %s", file);
log.logInfo("-> found %s (skipped %s)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public StaticAnalysisLabelProvider create(final String id) {
* @param name
* the name of the tool (might be empty or null)
*
* @return The label provider of the selected static analysis tool. If the tool is not found then a default label
* @return The label provider of the selected static analysis tool. If the tool is not found, then a default label
* provider is returned.
*/
public StaticAnalysisLabelProvider create(final String id, @CheckForNull final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@

private String pattern = StringUtils.EMPTY;
private String reportEncoding = StringUtils.EMPTY;
// Use negative case to allow defaulting to false and defaulting to existing behaviour.
private boolean skipSymbolicLinks = false;

/**
* Sets the Ant file-set pattern of files to work with. If the pattern is undefined then the console log is
* Sets the Ant file-set pattern of files to work with. If the pattern is undefined, then the console log is
* scanned.
*
* @param pattern
Expand Down Expand Up @@ -95,7 +94,7 @@
public abstract IssueParser createParser();

/**
* Specify if file scanning skip traversal of symbolic links.
* Specify if the file scanning step should skip the traversal of symbolic links.
*
* @param skipSymbolicLinks
* if symbolic links should be skipped during directory scanning.
Expand Down Expand Up @@ -180,6 +179,7 @@

List<Report> results = report.getResults();
Report aggregation;
// FIXME: properties are not set in the aggregation

Check warning on line 182 in plugin/src/main/java/io/jenkins/plugins/analysis/core/model/ReportScanningTool.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

FIXME

HIGH: properties are not set in the aggregation
if (results.isEmpty()) {
aggregation = new Report();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* build (started automatically or manually) will not evaluate a quality gate that considers the number of new warnings.
* This helps to start over from a clean state if the number of new warnings have been increased accidentally. Otherwise
* you won't get a successful build anymore until all new warnings have been fixed.
*
* <p>
* Technically, this command just adds a marker action to the selected build. Once a new build is running, this marker
* action will be checked for existence and the quality gate will be bypassed for one single build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@

import org.apache.commons.lang3.StringUtils;

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.util.Generated;
import edu.hm.hafner.util.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import org.kohsuke.stapler.StaplerProxy;
import org.kohsuke.stapler.bind.JavaScriptMethod;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
import org.jvnet.localizer.Localizable;
import hudson.model.Action;
import hudson.model.HealthReport;
import hudson.model.HealthReportingAction;
Expand Down Expand Up @@ -45,29 +50,9 @@ public class ResultAction implements HealthReportingAction, LastBuildAction, Run
private final HealthDescriptor healthDescriptor;
private final String id;
private final String name;
private /* almost final */ String icon;
private final String charset;
private TrendChartType trendChartType;

/**
* Creates a new instance of {@link ResultAction}.
*
* @param owner
* the associated build/run that created the static analysis result
* @param result
* the result of the static analysis run
* @param healthDescriptor
* the health descriptor of the static analysis run
* @param id
* the ID of the results
* @param name
* the optional name of the results
* @param charset
* the charset to use to display source files
*/
public ResultAction(final Run<?, ?> owner, final AnalysisResult result, final HealthDescriptor healthDescriptor,
final String id, final String name, final Charset charset) {
this(owner, result, healthDescriptor, id, name, charset, TrendChartType.AGGREGATION_TOOLS);
}
private /* almost final */ TrendChartType trendChartType;

/**
* Creates a new instance of {@link ResultAction}.
Expand All @@ -82,31 +67,39 @@ public ResultAction(final Run<?, ?> owner, final AnalysisResult result, final He
* the ID of the results
* @param name
* the optional name of the results
* @param icon
* the optional icon of the results
* @param charset
* the charset to use to display source files
* @param trendChartType
* determines if the trend chart will be shown
*/
@SuppressWarnings("checkstyle:ParameterNumber")
public ResultAction(final Run<?, ?> owner, final AnalysisResult result, final HealthDescriptor healthDescriptor,
final String id, final String name, final Charset charset, final TrendChartType trendChartType) {
final String id, final String name, final String icon,
final Charset charset, final TrendChartType trendChartType) {
this.owner = owner;
this.result = result;
this.healthDescriptor = healthDescriptor;
this.id = id;
this.name = name;
this.icon = icon;
this.charset = charset.name();
this.trendChartType = trendChartType;
}

/**
* Called after de-serialization to retain backward compatibility.
* Called after deserialization to retain backward compatibility.
*
* @return this
*/
protected Object readResolve() {
if (trendChartType == null) {
trendChartType = TrendChartType.TOOLS_ONLY;
}
if (icon == null) {
icon = StringUtils.EMPTY;
}
return this;
}

Expand Down Expand Up @@ -276,7 +269,6 @@ public String getSmallImageName() {
*
* @return the URL of the image
*/
@SuppressWarnings({"unused", "WeakerAccess"}) // Called by jelly view
public String getSmallImage() {
return getLabelProvider().getSmallIconUrl();
}
Expand Down Expand Up @@ -314,7 +306,20 @@ public String toString() {
* @return the label provider for this tool
*/
public StaticAnalysisLabelProvider getLabelProvider() {
return new LabelProviderFactory().create(id, name);
var registeredLabelProvider = new LabelProviderFactory().create(getParserId(), name);
if (StringUtils.isBlank(icon)) {
return registeredLabelProvider;
}

return new CustomIconLabelProvider(registeredLabelProvider, icon);
}

private String getParserId() {
var originalReport = getResult().getIssues();
if (originalReport.hasParserId()) {
return originalReport.getParserId();
}
return id;
}

/**
Expand All @@ -338,4 +343,98 @@ public String resetReference() {
// Empty method as workaround for Stapler bug that does not find JavaScript proxy methods in target object IssueDetail
return "{}";
}

private static class CustomIconLabelProvider extends StaticAnalysisLabelProvider {
@Override
public DetailsTableModel getIssuesModel(final Run<?, ?> build, final String url, final Report report) {
return decorated.getIssuesModel(build, url, report);
}

@Override
public DefaultAgeBuilder getAgeBuilder(final Run<?, ?> owner, final String url) {
return decorated.getAgeBuilder(owner, url);
}

@Override
public FileNameRenderer getFileNameRenderer(final Run<?, ?> owner) {
return decorated.getFileNameRenderer(owner);
}

@VisibleForTesting
@Override
public String getDefaultName() {
return decorated.getDefaultName();
}

@Override
public String getId() {
return decorated.getId();
}

@Override
public String getName() {
return decorated.getName();
}

@Override
public StaticAnalysisLabelProvider setName(@CheckForNull final String name) {
return decorated.setName(name);
}

@Override
@Generated
public String toString() {
return decorated.toString();
}

@Override
public String getLinkName() {
return decorated.getLinkName();
}

@Override
public String getTrendName() {
return decorated.getTrendName();
}

@Override
public String getToolTip(final int numberOfItems) {
return decorated.getToolTip(numberOfItems);
}

@Override
public Localizable getToolTipLocalizable(final int numberOfItems) {
return decorated.getToolTipLocalizable(numberOfItems);
}

@Override
public String getDescription(final Issue issue) {
return decorated.getDescription(issue);
}

@Override
public String getSourceCodeDescription(final Run<?, ?> build, final Issue issue) {
return decorated.getSourceCodeDescription(build, issue);
}

private final StaticAnalysisLabelProvider decorated;
private final String icon;

CustomIconLabelProvider(final StaticAnalysisLabelProvider decorated, final String icon) {
super(decorated.getId(), decorated.getName());
this.decorated = decorated;

this.icon = icon;
}

@Override
public String getSmallIconUrl() {
return icon;
}

@Override
public String getLargeIconUrl() {
return icon;
}
}
}
Loading
Loading