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 a51b7d2 commit 070456a
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 120 deletions.
Expand Up @@ -29,16 +29,20 @@ public class FindBugsAnnotationsAggregator 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 FindBugsAnnotationsAggregator(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 FindBugsResultAction(build, healthDescriptor,
new FindBugsResult(build, defaultEncoding, aggregatedResult));
new FindBugsResult(build, defaultEncoding, aggregatedResult, useOnlyStableBuildsAsReference()));
}

@Override
Expand Down
Expand Up @@ -28,7 +28,7 @@ public class FindBugsMavenResult extends FindBugsResult {
@SuppressWarnings("deprecation")
public FindBugsMavenResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
super(build, defaultEncoding, result, MavenFindBugsResultAction.class);
super(build, defaultEncoding, result, false, MavenFindBugsResultAction.class);
}

/** {@inheritDoc} */
Expand Down
Expand Up @@ -45,7 +45,7 @@ public FindBugsMavenResultAction(final AbstractBuild<?, ?> owner, final HealthDe
/** {@inheritDoc} */
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new FindBugsMavenResultAction(build, getHealthDescriptor(), getDisplayName(),
new FindBugsResult(build, getDefaultEncoding(), new ParserResult()));
new FindBugsResult(build, getDefaultEncoding(), new ParserResult(), false));
}

/** {@inheritDoc} */
Expand All @@ -60,7 +60,8 @@ public Class<? extends MavenResultAction<FindBugsResult>> getIndividualActionTyp

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

Expand Up @@ -90,6 +90,8 @@ public class FindBugsPublisher 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
Expand All @@ -111,14 +113,14 @@ public FindBugsPublisher(final String healthy, final String unHealthy, final Str
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 canRunOnFailed, final boolean useStableBuildAsReference, final boolean shouldDetectModules,
final String pattern, final boolean isRankActivated, final boolean canComputeNew) {
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, false, PLUGIN_NAME);
this.pattern = pattern;
this.isRankActivated = isRankActivated;
}
Expand Down Expand Up @@ -158,7 +160,7 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
new FindBugsParser(isRankActivated), shouldDetectModules(), isMavenBuild(build));
ParserResult project = build.getWorkspace().act(collector);
logger.logLines(project.getLogMessages());
FindBugsResult result = new FindBugsResult(build, getDefaultEncoding(), project);
FindBugsResult result = new FindBugsResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference());

build.getActions().add(new FindBugsResultAction(build, this, result));

Expand All @@ -173,6 +175,6 @@ public FindBugsDescriptor getDescriptor() {
/** {@inheritDoc} */
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new FindBugsAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding());
return new FindBugsAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
}
}
Expand Up @@ -91,6 +91,8 @@ public class FindBugsReporter extends HealthAwareReporter<FindBugsResult> {
* 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 isRankActivated
* determines whether to use the rank when evaluation the
* priority
Expand All @@ -106,13 +108,13 @@ public FindBugsReporter(final String healthy, final String unHealthy, final Stri
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 isRankActivated, final boolean canComputeNew) {
final boolean canRunOnFailed, final boolean useStableBuildAsReference, final boolean isRankActivated, final boolean canComputeNew) {
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.isRankActivated = isRankActivated;
}
// CHECKSTYLE:ON
Expand Down Expand Up @@ -173,7 +175,7 @@ public ParserResult perform(final MavenBuildProxy build, final MavenProject pom,

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

@Override
Expand Down
Expand Up @@ -22,10 +22,13 @@ public class FindBugsReporterResult extends FindBugsResult {
* 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 FindBugsReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
super(build, defaultEncoding, result, FindBugsMavenResultAction.class);
final ParserResult result, final boolean useStableBuildAsReference) {
super(build, defaultEncoding, result, useStableBuildAsReference, FindBugsMavenResultAction.class);
}

@Override
Expand Down
14 changes: 10 additions & 4 deletions plugin/src/main/java/hudson/plugins/findbugs/FindBugsResult.java
Expand Up @@ -34,10 +34,13 @@ public class FindBugsResult 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 FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
this(build, defaultEncoding, result, FindBugsResultAction.class);
final ParserResult result, final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, useStableBuildAsReference, FindBugsResultAction.class);
}

/**
Expand All @@ -49,12 +52,15 @@ public FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncod
* 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 FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final Class<? extends ResultAction<FindBugsResult>> actionType) {
this(build, new BuildHistory(build, actionType), result, defaultEncoding, true);
final boolean useStableBuildAsReference, final Class<? extends ResultAction<FindBugsResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding, true);
}

FindBugsResult(final AbstractBuild<?, ?> build, final BuildHistory history,
Expand Down
@@ -1,9 +1,9 @@
package hudson.plugins.findbugs;

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 FindBugs results. This action persists the
Expand Down Expand Up @@ -31,18 +31,6 @@ public FindBugsResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip
super(owner, new FindBugsHealthDescriptor(healthDescriptor), result);
}

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

/** {@inheritDoc} */
public String getDisplayName() {
return Messages.FindBugs_ProjectAction_Name();
Expand Down
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 MavenFindBugsResultAction extends FindBugsResultAction implements A
/** The default encoding to be used when reading and parsing files. */
private final String defaultEncoding;

/**
* Creates a new instance of <code>MavenFindBugsResultAction</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 MavenFindBugsResultAction(final MavenModuleSetBuild owner, final HealthDescriptor healthDescriptor,
final String defaultEncoding) {
super(owner, healthDescriptor);
this.defaultEncoding = defaultEncoding;
}

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

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

/** {@inheritDoc} */
Expand Down
@@ -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:fb="/findbugs">
<f:entry title="${%FindBugs results}" field="pattern"
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox/>
</f:entry>
<fb:rank/>
<f:advanced>
<u:advanced id="findbugs"/>
<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:fb="/findbugs">
<f:entry title="${%FindBugs results}" field="pattern"
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox />
</f:entry>
<fb:rank />
<f:advanced>
<u:advanced id="findbugs" />
</f:advanced>
</j:jelly>

1 comment on commit 070456a

@buildhive
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jenkins » findbugs-plugin #52 FAILURE
Looks like this commit caused a build failure
(what's this?)

Please sign in to comment.