Skip to content

Commit

Permalink
Violations-lib 1.29 with reporter field
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jul 15, 2017
1 parent f655d1a commit a20cf15
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 84 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Changelog of Violation Comments to Bitbucket Server Plugin.
## Unreleased
### No issue

**Violations-lib 1.29 with reporter field**


[4c7a4dbd799175c](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/4c7a4dbd799175c) Tomas Bjerre *2017-07-15 13:37:30*

**Updating doc on Infer**


[f655d1abb667a16](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/f655d1abb667a16) Tomas Bjerre *2017-06-23 12:54:11*

**doc**


[491121e6e5978ac](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/491121e6e5978ac) Tomas Bjerre *2017-06-13 18:01:57*

**Correcting PULL_REQUEST_ID in example DSL**


Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,15 @@ git --no-pager log --max-count=10 --graph --abbrev-commit
violationConfigs {
violationConfig {
reporter("FINDBUGS")
parser("FINDBUGS")
reporter("Findbugs")
pattern(".*/findbugs/.*\\.xml\$")
}
violationConfig {
parser("CHECKSTYLE")
reporter("Checkstyle")
pattern(".*/checkstyle/.*\\.xml\$")
}
}
}
}
Expand Down Expand Up @@ -261,8 +267,9 @@ node {
useUsernamePasswordCredentials: false,
minSeverity: 'INFO',
violationConfigs: [
[ pattern: '.*/checkstyle/.*\\.xml$', reporter: 'CHECKSTYLE' ],
[ pattern: '.*/findbugs/.*\\.xml$', reporter: 'FINDBUGS' ],
[ pattern: '.*/checkstyle-result\\.xml$', parser: 'CHECKSTYLE', reporter: 'Checkstyle' ],
[ pattern: '.*/findbugsXml\\.xml$', parser: 'FINDBUGS', reporter: 'Findbugs' ],
[ pattern: '.*/pmd\\.xml$', parser: 'PMD', reporter: 'PMD' ],
]
]
])
Expand Down
14 changes: 11 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -73,7 +74,7 @@
<url>https://repo.jenkins-ci.org/snapshots</url>
</snapshotRepository>
</distributionManagement>

<build>
<plugins>
<plugin>
Expand All @@ -99,6 +100,13 @@
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>se.bjurr.gitchangelog</groupId>
<artifactId>git-changelog-maven-plugin</artifactId>
Expand Down Expand Up @@ -196,7 +204,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin.
<dependency>
<groupId>se.bjurr.violations</groupId>
<artifactId>violation-comments-to-bitbucket-server-lib</artifactId>
<version>1.26</version>
<version>1.27</version>
</dependency>

<!-- test // -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_PATTERN;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_PROJECTKEY;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_PULLREQUESTID;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_REPORTER;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_REPOSLUG;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_USERNAME;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_USERNAMEPASSWORDCREDENTIALSID;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_USEUSERNAMEPASSWORD;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_USEUSERNAMEPASSWORDCREDENTIALS;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.createNewConfig;
import hudson.model.AbstractProject;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.ListBoxModel;

import java.util.List;

import net.sf.json.JSONObject;

import org.jenkinsci.plugins.jvctb.config.CredentialsHelper;
import org.jenkinsci.plugins.jvctb.config.ViolationConfig;
import org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfig;
import org.kohsuke.stapler.StaplerRequest;

import hudson.model.AbstractProject;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.ListBoxModel;
import net.sf.json.JSONObject;
import se.bjurr.violations.lib.model.SEVERITY;

public final class ViolationsToBitbucketServerDescriptor extends BuildStepDescriptor<Publisher> {
Expand Down Expand Up @@ -105,8 +108,14 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData)
}

int i = 0;
for (String pattern : (List<String>) formData.get(FIELD_PATTERN)) {
config.getViolationConfigs().get(i++).setPattern(pattern);
List<String> patterns = (List<String>) formData.get(FIELD_PATTERN);
List<String> reporters = (List<String>) formData.get(FIELD_REPORTER);
for (String pattern : patterns) {
ViolationConfig violationConfig = config.getViolationConfigs().get(i);
violationConfig.setPattern(pattern);
String reporter = reporters.get(i);
violationConfig.setReporter(reporter);
i++;
}
ViolationsToBitbucketServerRecorder publisher = new ViolationsToBitbucketServerRecorder();
publisher.setConfig(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

import org.kohsuke.stapler.DataBoundConstructor;

import se.bjurr.violations.lib.reports.Reporter;
import se.bjurr.violations.lib.reports.Parser;

public class ViolationConfig implements Serializable {
private static final long serialVersionUID = 6664329842273455651L;
private String pattern;
private Reporter reporter;
private String reporter;
private Parser parser;

public ViolationConfig() {}

@DataBoundConstructor
public ViolationConfig(Reporter reporter, String pattern) {
public ViolationConfig(String reporter, String pattern, Parser parser) {
this.reporter = reporter;
this.pattern = pattern;
this.parser = parser;
}

@Override
Expand All @@ -31,14 +33,21 @@ public boolean equals(Object obj) {
return false;
}
ViolationConfig other = (ViolationConfig) obj;
if (this.pattern == null) {
if (parser != other.parser) {
return false;
}
if (pattern == null) {
if (other.pattern != null) {
return false;
}
} else if (!this.pattern.equals(other.pattern)) {
} else if (!pattern.equals(other.pattern)) {
return false;
}
if (this.reporter != other.reporter) {
if (reporter == null) {
if (other.reporter != null) {
return false;
}
} else if (!reporter.equals(other.reporter)) {
return false;
}
return true;
Expand All @@ -48,29 +57,44 @@ public String getPattern() {
return this.pattern;
}

public Reporter getReporter() {
public String getReporter() {
return this.reporter;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.pattern == null) ? 0 : this.pattern.hashCode());
result = prime * result + ((this.reporter == null) ? 0 : this.reporter.hashCode());
result = prime * result + (parser == null ? 0 : parser.hashCode());
result = prime * result + (pattern == null ? 0 : pattern.hashCode());
result = prime * result + (reporter == null ? 0 : reporter.hashCode());
return result;
}

public void setPattern(String pattern) {
this.pattern = pattern;
}

public void setReporter(Reporter reporter) {
public void setParser(Parser parser) {
this.parser = parser;
}

public Parser getParser() {
return parser;
}

public void setReporter(String reporter) {
this.reporter = reporter;
}

@Override
public String toString() {
return "ViolationConfig [reporter=" + this.reporter + ", pattern=" + this.pattern + "]";
return "ViolationConfig [pattern="
+ pattern
+ ", reporter="
+ reporter
+ ", parser="
+ parser
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ private List<ViolationConfig> includeAllReporters(List<ViolationConfig> violatio
ViolationsToBitbucketServerConfigHelper.getAllViolationConfigs();
for (ViolationConfig candidate : allViolationConfigs) {
for (ViolationConfig input : violationConfigs) {
if (candidate.getReporter() == input.getReporter()) {
if (candidate.getParser() == input.getParser()) {
candidate.setPattern(input.getPattern());
candidate.setReporter(input.getReporter());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.util.List;

import se.bjurr.violations.lib.reports.Reporter;
import se.bjurr.violations.lib.reports.Parser;

public class ViolationsToBitbucketServerConfigHelper {
public static final String FIELD_BITBUCKETSERVERURL = "bitbucketServerUrl";
Expand Down Expand Up @@ -36,9 +36,9 @@ public static ViolationsToBitbucketServerConfig createNewConfig() {

public static List<ViolationConfig> getAllViolationConfigs() {
List<ViolationConfig> violationConfigs = newArrayList();
for (Reporter reporter : Reporter.values()) {
for (Parser parser : Parser.values()) {
ViolationConfig violationConfig = new ViolationConfig();
violationConfig.setReporter(reporter);
violationConfig.setParser(parser);
violationConfigs.add(violationConfig);
}
return violationConfigs;
Expand Down
Loading

0 comments on commit a20cf15

Please sign in to comment.