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

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-30103] @jglick's comments have been reviewed
  • Loading branch information
Manuel Recena authored and recena committed Aug 25, 2015
1 parent 667bf23 commit 0f8c4d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
31 changes: 19 additions & 12 deletions src/main/java/hudson/plugins/dry/DryPublisher.java
Expand Up @@ -40,15 +40,13 @@ public class DryPublisher extends HealthAwarePublisher {
private String pattern;

/** Minimum number of duplicate lines for high priority warnings. @since 2.5 */
private int highThreshold;
private int highThreshold = 50;
/** Minimum number of duplicate lines for normal priority warnings. @since 2.5 */
private int normalThreshold;
private int normalThreshold = 25;

@DataBoundConstructor
public DryPublisher(final int highThreshold, final int normalThreshold) {
public DryPublisher() {
super(PLUGIN_NAME);
this.highThreshold = highThreshold;
this.normalThreshold = normalThreshold;
}

/**
Expand Down Expand Up @@ -86,6 +84,16 @@ public void setPattern(final String pattern) {
this.pattern = pattern;
}

@DataBoundSetter
public void setHighThreshold(final int highThreshold) {
this.highThreshold = highThreshold;
}

@DataBoundSetter
public void setNormalThreshold(final int normalThreshold) {
this.normalThreshold = normalThreshold;
}

@Override
public Action getProjectAction(final AbstractProject<?, ?> project) {
return new DryProjectAction(project);
Expand All @@ -96,17 +104,16 @@ public BuildResult perform(final Run<?, ?> build, final FilePath workspace, fina
InterruptedException, IOException {
logger.log("Collecting duplicate code analysis files...");

FilesParser dryCollector = new FilesParser(PLUGIN_NAME, StringUtils.defaultIfEmpty(getPattern(),
DEFAULT_DRY_PATTERN),
new DuplicationParserRegistry(getNormalThreshold(), getHighThreshold(), workspace.getRemote(),
getDefaultEncoding()),
shouldDetectModules(), isMavenBuild(build));
FilesParser dryCollector = new FilesParser(PLUGIN_NAME, StringUtils.defaultIfEmpty(getPattern(), DEFAULT_DRY_PATTERN),
new DuplicationParserRegistry(getNormalThreshold(), getHighThreshold(), workspace.getRemote(),
getDefaultEncoding()),
shouldDetectModules(), isMavenBuild(build));

ParserResult project = workspace.act(dryCollector);
logger.logLines(project.getLogMessages());

DryResult result = new DryResult(build, getDefaultEncoding(), project, usePreviousBuildAsReference(),
useOnlyStableBuildsAsReference());
DryResult result = new DryResult(build, getDefaultEncoding(), project,
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
build.addAction(new DryResultAction(build, this, result));

return result;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/dry/DryReporterResult.java
@@ -1,6 +1,5 @@
package hudson.plugins.dry;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.ResultAction;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/hudson/plugins/dry/DryWorkflowTest.java
Expand Up @@ -38,7 +38,7 @@ public void dryPublisherWorkflowStep() throws Exception {
+ "node {\n"
+ " def mvnHome = tool '" + mavenInstallation.getName() + "'\n"
+ " sh \"${mvnHome}/bin/mvn clean install\"\n"
+ " step([$class: 'DryPublisher', highThreshold: 50, normalThreshold: 25])\n"
+ " step([$class: 'DryPublisher'])\n"
+ "}\n", true)
);
jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
Expand Down

0 comments on commit 0f8c4d3

Please sign in to comment.