Skip to content

Commit

Permalink
Ignoring violation configs with null config #36
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 11, 2017
1 parent 5e436b2 commit 0f4e034
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
Changelog of Violation Comments to Bitbucket Server Plugin.

## Unreleased
### GitHub [#36](https://github.com/jenkinsci/violation-comments-to-stash-plugin/issues/36) java.lang.NullPointerException from violations-lib

**Ignoring violation configs with null config #36**


[3371d0a64306695](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/3371d0a64306695) Tomas Bjerre *2017-08-11 10:17:17*


### No issue

**doc**


[660761046a7050b](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/660761046a7050b) Tomas Bjerre *2017-08-02 15:38:11*
[5e436b254438d7f](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/5e436b254438d7f) Tomas Bjerre *2017-08-02 15:38:36*


## 1.52
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,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.28</version>
<version>1.29</version>
</dependency>

<!-- test // -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static se.bjurr.violations.comments.bitbucketserver.lib.ViolationCommentsToBitbucketServerApi.violationCommentsToBitbucketServerApi;
import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi;
import static se.bjurr.violations.lib.parsers.FindbugsParser.setFindbugsMessagesXml;
import static se.bjurr.violations.lib.util.Filtering.withAtLEastSeverity;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.FilePath.FileCallable;
Expand All @@ -46,14 +47,15 @@

import se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.util.Filtering;
import se.bjurr.violations.lib.reports.Parser;

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.io.CharStreams;

public class JvctbPerformer {
private static Logger LOG = Logger.getLogger(JvctbPerformer.class.getSimpleName());

@VisibleForTesting
public static void doPerform(
Expand All @@ -80,9 +82,9 @@ public static void doPerform(
.inFolder(workspace.getAbsolutePath()) //
.withPattern(violationConfig.getPattern()) //
.violations();
SEVERITY minSeverity = config.getMinSeverity();
final SEVERITY minSeverity = config.getMinSeverity();
if (minSeverity != null) {
parsedViolations = Filtering.withAtLEastSeverity(parsedViolations, minSeverity);
parsedViolations = withAtLEastSeverity(parsedViolations, minSeverity);
}

allParsedViolations.addAll(parsedViolations);
Expand Down Expand Up @@ -153,10 +155,17 @@ static ViolationsToBitbucketServerConfig expand(
expanded.setMinSeverity(config.getMinSeverity());

for (final ViolationConfig violationConfig : config.getViolationConfigs()) {
final String pattern = environment.expand(violationConfig.getPattern());
final String reporter = violationConfig.getReporter();
final Parser parser = violationConfig.getParser();
if (isNullOrEmpty(pattern) || isNullOrEmpty(reporter) || parser == null) {
LOG.fine("Ignoring violationConfig because of null/empty -values: " + violationConfig);
continue;
}
final ViolationConfig p = new ViolationConfig();
p.setPattern(environment.expand(violationConfig.getPattern()));
p.setReporter(violationConfig.getReporter());
p.setParser(violationConfig.getParser());
p.setPattern(pattern);
p.setReporter(reporter);
p.setParser(parser);
expanded.getViolationConfigs().add(p);
}
return expanded;
Expand Down Expand Up @@ -209,7 +218,7 @@ private static void logConfiguration(
final ViolationsToBitbucketServerConfig config,
final Run<?, ?> build,
final TaskListener listener) {
PrintStream logger = listener.getLogger();
final PrintStream logger = listener.getLogger();
logger.println(FIELD_BITBUCKETSERVERURL + ": " + config.getBitbucketServerUrl());
logger.println(FIELD_PROJECTKEY + ": " + config.getProjectKey());
logger.println(FIELD_REPOSLUG + ": " + config.getRepoSlug());
Expand Down

0 comments on commit 0f4e034

Please sign in to comment.