Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[JENKINS-15037]: Upgrade to new API in order to compute warnings only
Browse files Browse the repository at this point in the history
for stable builds (if option is checked).
  • Loading branch information
uhafner committed Sep 28, 2012
1 parent 39ee4e0 commit a715b62
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 60 deletions.
10 changes: 7 additions & 3 deletions src/main/java/hudson/plugins/dry/DryAnnotationsAggregator.java
Expand Up @@ -30,16 +30,20 @@ public class DryAnnotationsAggregator extends AnnotationsAggregator {
* health descriptor
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public DryAnnotationsAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener, final HealthDescriptor healthDescriptor, final String defaultEncoding) {
super(build, launcher, listener, healthDescriptor, defaultEncoding);
final BuildListener listener, final HealthDescriptor healthDescriptor, final String defaultEncoding,
final boolean useStableBuildAsReference) {
super(build, launcher, listener, healthDescriptor, defaultEncoding, useStableBuildAsReference);
}

@Override
protected Action createAction(final HealthDescriptor healthDescriptor, final String defaultEncoding, final ParserResult aggregatedResult) {
return new DryResultAction(build, healthDescriptor,
new DryResult(build, defaultEncoding, aggregatedResult));
new DryResult(build, defaultEncoding, aggregatedResult, useOnlyStableBuildsAsReference()));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/dry/DryMavenResult.java
Expand Up @@ -29,7 +29,7 @@ public class DryMavenResult extends DryResult {
@SuppressWarnings("deprecation")
public DryMavenResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
super(build, defaultEncoding, result, MavenDryResultAction.class);
super(build, defaultEncoding, result, false, MavenDryResultAction.class);
}

/** {@inheritDoc} */
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/hudson/plugins/dry/DryMavenResultAction.java
Expand Up @@ -42,7 +42,7 @@ public DryMavenResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip
/** {@inheritDoc} */
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new DryMavenResultAction(build, getHealthDescriptor(), getDisplayName(),
new DryResult(build, getDefaultEncoding(), new ParserResult()));
new DryResult(build, getDefaultEncoding(), new ParserResult(), false));
}

/** {@inheritDoc} */
Expand All @@ -57,7 +57,8 @@ public Class<? extends MavenResultAction<DryResult>> getIndividualActionType() {

@Override
protected DryResult createResult(final DryResult existingResult, final DryResult additionalResult) {
return new DryReporterResult(getOwner(), additionalResult.getDefaultEncoding(), aggregate(existingResult, additionalResult));
return new DryReporterResult(getOwner(), additionalResult.getDefaultEncoding(),
aggregate(existingResult, additionalResult), existingResult.useOnlyStableBuildsAsReference());
}
}

12 changes: 7 additions & 5 deletions src/main/java/hudson/plugins/dry/DryPublisher.java
Expand Up @@ -94,6 +94,8 @@ public class DryPublisher extends HealthAwarePublisher {
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param shouldDetectModules
* determines whether module names should be derived from Maven POM or Ant build files
* @param canComputeNew
Expand All @@ -115,14 +117,14 @@ public DryPublisher(final String healthy, final String unHealthy, final String t
final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow,
final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow,
final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow,
final boolean canRunOnFailed, final boolean shouldDetectModules, final boolean canComputeNew,
final String pattern, final int highThreshold, final int normalThreshold) {
final boolean canRunOnFailed, final boolean useStableBuildAsReference, final boolean shouldDetectModules,
final boolean canComputeNew, final String pattern, final int highThreshold, final int normalThreshold) {
super(healthy, unHealthy, thresholdLimit, defaultEncoding, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, shouldDetectModules, canComputeNew, PLUGIN_NAME);
canRunOnFailed, useStableBuildAsReference, shouldDetectModules, canComputeNew, true, PLUGIN_NAME);
this.pattern = pattern;
this.highThreshold = highThreshold;
this.normalThreshold = normalThreshold;
Expand Down Expand Up @@ -173,7 +175,7 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
ParserResult project = build.getWorkspace().act(dryCollector);
logger.logLines(project.getLogMessages());

DryResult result = new DryResult(build, getDefaultEncoding(), project);
DryResult result = new DryResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference());
build.getActions().add(new DryResultAction(build, this, result));

return result;
Expand All @@ -187,6 +189,6 @@ public DryDescriptor getDescriptor() {
/** {@inheritDoc} */
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new DryAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding());
return new DryAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
}
}
8 changes: 5 additions & 3 deletions src/main/java/hudson/plugins/dry/DryReporter.java
Expand Up @@ -88,6 +88,8 @@ public class DryReporter extends HealthAwareReporter<DryResult> {
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param canComputeNew
* determines whether new warnings should be computed (with
* respect to baseline)
Expand All @@ -104,14 +106,14 @@ public DryReporter(final String healthy, final String unHealthy, final String th
final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow,
final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow,
final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow,
final boolean canRunOnFailed, final boolean canComputeNew,
final boolean canRunOnFailed, final boolean useStableBuildAsReference, final boolean canComputeNew,
final int highThreshold, final int normalThreshold) {
super(healthy, unHealthy, thresholdLimit, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, canComputeNew, PLUGIN_NAME);
canRunOnFailed, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
this.highThreshold = highThreshold;
this.normalThreshold = normalThreshold;
}
Expand Down Expand Up @@ -152,7 +154,7 @@ public ParserResult perform(final MavenBuildProxy build, final MavenProject pom,

@Override
protected DryResult createResult(final MavenBuild build, final ParserResult project) {
return new DryReporterResult(build, getDefaultEncoding(), project);
return new DryReporterResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference());
}

@Override
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/hudson/plugins/dry/DryReporterResult.java
Expand Up @@ -22,10 +22,13 @@ public class DryReporterResult extends DryResult {
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public DryReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
super(build, defaultEncoding, result, DryMavenResultAction.class);
final ParserResult result, final boolean useStableBuildAsReference) {
super(build, defaultEncoding, result, useStableBuildAsReference, DryMavenResultAction.class);
}

@Override
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/hudson/plugins/dry/DryResult.java
Expand Up @@ -27,9 +27,13 @@ public class DryResult extends BuildResult {
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public DryResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result) {
this(build, defaultEncoding, result, DryResultAction.class);
public DryResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, useStableBuildAsReference, DryResultAction.class);
}

/**
Expand All @@ -41,12 +45,15 @@ public DryResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @param actionType
* the type of the result action
*/
protected DryResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final Class<? extends ResultAction<DryResult>> actionType) {
this(build, new BuildHistory(build, actionType), result, defaultEncoding, true);
final boolean useStableBuildAsReference, final Class<? extends ResultAction<DryResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding, true);
}

DryResult(final AbstractBuild<?, ?> build, final BuildHistory history,
Expand Down
14 changes: 1 addition & 13 deletions src/main/java/hudson/plugins/dry/DryResultAction.java
@@ -1,9 +1,9 @@
package hudson.plugins.dry;

import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.AbstractResultAction;
import hudson.plugins.analysis.core.HealthDescriptor;
import hudson.plugins.analysis.core.PluginDescriptor;
import hudson.plugins.analysis.core.AbstractResultAction;

/**
* Controls the live cycle of the DRY results. This action persists the
Expand Down Expand Up @@ -31,18 +31,6 @@ public DryResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor h
super(owner, new DryHealthDescriptor(healthDescriptor), result);
}

/**
* Creates a new instance of <code>PmdResultAction</code>.
*
* @param owner
* the associated build of this action
* @param healthDescriptor
* health descriptor to use
*/
public DryResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor healthDescriptor) {
super(owner, new DryHealthDescriptor(healthDescriptor));
}

/** {@inheritDoc} */
public String getDisplayName() {
return Messages.DRY_ProjectAction_Name();
Expand Down
20 changes: 3 additions & 17 deletions src/main/java/hudson/plugins/dry/MavenDryResultAction.java
Expand Up @@ -9,6 +9,7 @@
import hudson.model.Action;
import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.HealthDescriptor;
import hudson.plugins.analysis.core.ParserResult;

import java.util.List;
import java.util.Map;
Expand All @@ -26,22 +27,6 @@ public class MavenDryResultAction extends DryResultAction implements Aggregatabl
/** The default encoding to be used when reading and parsing files. */
private final String defaultEncoding;

/**
* Creates a new instance of <code>MavenPmdResultAction</code>.
*
* @param owner
* the associated build of this action
* @param healthDescriptor
* health descriptor to use
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
*/
public MavenDryResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor healthDescriptor,
final String defaultEncoding) {
super(owner, healthDescriptor);
this.defaultEncoding = defaultEncoding;
}

/**
* Creates a new instance of <code>MavenPmdResultAction</code>.
*
Expand All @@ -62,7 +47,8 @@ public MavenDryResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip

/** {@inheritDoc} */
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenDryResultAction(build, getHealthDescriptor(), defaultEncoding);
return new MavenDryResultAction(build, getHealthDescriptor(), defaultEncoding,
new DryResult(build, defaultEncoding, new ParserResult(), false));
}

/** {@inheritDoc} */
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/hudson/plugins/dry/DryPublisher/config.jelly
@@ -1,12 +1,12 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util" xmlns:p="/dry">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util" xmlns:p="/dry">
<f:entry title="${%Duplicate code results}" field="pattern"
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox />
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox />
</f:entry>
<p:priorities/>
<p:priorities />
<f:advanced>
<u:advanced id="dry"/>
<u:advanced id="dry" />
</f:advanced>
</j:jelly>
@@ -1,8 +1,8 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util" xmlns:p="/dry">
<p:priorities/>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util" xmlns:p="/dry">
<p:priorities />
<f:advanced>
<u:advancedMaven id="dry"/>
<u:advancedMaven id="dry" />
</f:advanced>
</j:jelly>

0 comments on commit a715b62

Please sign in to comment.