Skip to content
Permalink
Browse files

[FIXED JENKINS-13458] Added an option to use previous build as a refe…

…rence.
  • Loading branch information
uhafner committed Jan 5, 2015
1 parent 6bf70c3 commit ee4a8b6203a4caf10855dd8ddf5341a6f55e08ee
@@ -30,20 +30,26 @@
* health descriptor
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param usePreviousBuildAsReference
* determines whether the previous build should be used as the
* reference build
* @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,
final boolean useStableBuildAsReference) {
super(build, launcher, listener, healthDescriptor, defaultEncoding, useStableBuildAsReference);
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
super(build, launcher, listener, healthDescriptor, defaultEncoding,
usePreviousBuildAsReference, useStableBuildAsReference);
}

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

@Override
@@ -29,7 +29,7 @@
@SuppressWarnings("deprecation")
public DryMavenResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
super(build, defaultEncoding, result, false, MavenDryResultAction.class);
super(build, defaultEncoding, result, false, false, MavenDryResultAction.class);
}

@SuppressWarnings("deprecation")
@@ -42,7 +42,7 @@ public DryMavenResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new DryMavenResultAction(build, getHealthDescriptor(), getDefaultEncoding(),
new DryResult(build, getDefaultEncoding(), new ParserResult(), false));
new DryResult(build, getDefaultEncoding(), new ParserResult(), false, false));
}

@Override
@@ -58,7 +58,9 @@ public Action getProjectAction(final MavenModuleSet moduleSet) {
@Override
protected DryResult createResult(final DryResult existingResult, final DryResult additionalResult) {
return new DryReporterResult(getOwner(), additionalResult.getDefaultEncoding(),
aggregate(existingResult, additionalResult), existingResult.useOnlyStableBuildsAsReference());
aggregate(existingResult, additionalResult),
existingResult.usePreviousBuildAsStable(),
existingResult.useOnlyStableBuildsAsReference());
}
}

@@ -1,24 +1,24 @@
package hudson.plugins.dry;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Launcher;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixBuild;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.core.FilesParser;
import hudson.plugins.analysis.core.HealthAwarePublisher;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.util.PluginLogger;
import hudson.plugins.dry.parser.DuplicationParserRegistry;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Publishes the results of the duplicate code analysis (freestyle project type).
*
@@ -94,6 +94,8 @@
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determines whether to always use the previous build as the reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param shouldDetectModules
@@ -117,14 +119,16 @@ 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 useStableBuildAsReference, final boolean shouldDetectModules,
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference,
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, useStableBuildAsReference, shouldDetectModules, canComputeNew, true, PLUGIN_NAME);
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, shouldDetectModules,
canComputeNew, true, PLUGIN_NAME);
this.pattern = pattern;
this.highThreshold = highThreshold;
this.normalThreshold = normalThreshold;
@@ -175,8 +179,9 @@ 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, useOnlyStableBuildsAsReference());
build.getActions().add(new DryResultAction(build, this, result));
DryResult result = new DryResult(build, getDefaultEncoding(), project,
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
build.addAction(new DryResultAction(build, this, result));

return result;
}
@@ -189,6 +194,7 @@ public DryDescriptor getDescriptor() {
@Override
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new DryAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
return new DryAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(),
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
}
}
@@ -1,23 +1,23 @@
package hudson.plugins.dry;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import org.apache.maven.project.MavenProject;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.maven.MavenAggregatedReport;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MojoInfo;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenModule;
import hudson.maven.MojoInfo;
import hudson.plugins.analysis.core.FilesParser;
import hudson.plugins.analysis.core.HealthAwareReporter;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.util.PluginLogger;
import hudson.plugins.dry.parser.DuplicationParserRegistry;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import org.apache.maven.project.MavenProject;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Publishes the results of the duplicate code analysis (maven 2 project type).
*
@@ -88,6 +88,8 @@
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determines whether to always use the previous build as the reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param canComputeNew
@@ -106,14 +108,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 useStableBuildAsReference, final boolean canComputeNew,
final int highThreshold, final int normalThreshold) {
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, 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, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
this.highThreshold = highThreshold;
this.normalThreshold = normalThreshold;
}
@@ -154,7 +156,8 @@ 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, useOnlyStableBuildsAsReference());
return new DryReporterResult(build, getDefaultEncoding(), project,
usePreviousBuildAsStable(), useOnlyStableBuildsAsReference());
}

@Override
@@ -22,13 +22,17 @@
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param usePreviousBuildAsReference
* determines whether to use the previous build as the reference
* build
* @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, final boolean useStableBuildAsReference) {
super(build, defaultEncoding, result, useStableBuildAsReference, DryMavenResultAction.class);
public DryReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
super(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
DryMavenResultAction.class);
}

@Override
@@ -1,14 +1,14 @@
package hudson.plugins.dry;

import com.thoughtworks.xstream.XStream;

import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.ResultAction;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.dry.parser.DuplicateCode;

import com.thoughtworks.xstream.XStream;

/**
* Represents the results of the DRY analysis. One instance of this class is persisted for
* each build via an XML file.
@@ -27,13 +27,17 @@
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param usePreviousBuildAsReference
* determines whether to use the previous build as the reference
* build
* @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,
final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, useStableBuildAsReference, DryResultAction.class);
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
DryResultAction.class);
}

/**
@@ -45,15 +49,20 @@ 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 usePreviousBuildAsReference
* determines whether to use the previous build as the reference
* build
* @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 boolean useStableBuildAsReference, final Class<? extends ResultAction<DryResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding, true);
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final Class<? extends ResultAction<DryResult>> actionType) {
this(build, new BuildHistory(build, actionType, usePreviousBuildAsReference, useStableBuildAsReference),
result, defaultEncoding, true);
}

DryResult(final AbstractBuild<?, ?> build, final BuildHistory history,
@@ -1,19 +1,19 @@
package hudson.plugins.dry;

import java.util.List;
import java.util.Map;

import hudson.maven.AggregatableAction;
import hudson.maven.MavenAggregatedReport;
import hudson.maven.MavenBuild;
import hudson.maven.MavenModule;
import hudson.maven.MavenModuleSet;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.Action;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.plugins.analysis.core.HealthDescriptor;
import hudson.plugins.analysis.core.ParserResult;

import java.util.List;
import java.util.Map;

/**
* A {@link DryResultAction} for native maven jobs. This action
* additionally provides result aggregation for sub-modules and for the main
@@ -48,7 +48,7 @@ public MavenDryResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenDryResultAction(build, getHealthDescriptor(), defaultEncoding,
new DryResult(build, defaultEncoding, new ParserResult(), false));
new DryResult(build, defaultEncoding, new ParserResult(), false, false));
}

@Override

0 comments on commit ee4a8b6

Please sign in to comment.