Skip to content

Commit

Permalink
Checking for null in API-calls
Browse files Browse the repository at this point in the history
 * For better error messages.
  • Loading branch information
tomasbjerre committed Aug 11, 2017
1 parent b73430f commit 2147659
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ Changelog of Git Changelog.
## Unreleased
### No issue

**Checking for null in API-calls**

* For better error messages.

[18c745ae65282d7](https://github.com/tomasbjerre/violations-lib/commit/18c745ae65282d7) Tomas Bjerre *2017-08-11 09:42:01*

**Testing with reporter**


[b68214779e22b79](https://github.com/tomasbjerre/violations-lib/commit/b68214779e22b79) Tomas Bjerre *2017-07-14 19:30:01*
[b73430f34a55ff6](https://github.com/tomasbjerre/violations-lib/commit/b73430f34a55ff6) Tomas Bjerre *2017-07-14 19:31:04*


## 1.29
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/se/bjurr/violations/lib/ViolationsReporterApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.logging.Level.FINE;
import static se.bjurr.violations.lib.reports.ReportsFinder.findAllReports;
import static se.bjurr.violations.lib.util.Utils.checkNotNull;
import static se.bjurr.violations.lib.util.Utils.setReporter;

import java.io.File;
Expand All @@ -27,41 +28,41 @@ public static ViolationsReporterApi violationsReporterApi() {
private ViolationsReporterApi() {}

public ViolationsReporterApi findAll(Parser parser) {
this.parser = parser;
this.parser = checkNotNull(parser, "parser");
return this;
}

public ViolationsReporterApi withReporter(String reporter) {
this.reporter = reporter;
this.reporter = checkNotNull(reporter, "reporter");
return this;
}

public ViolationsReporterApi inFolder(String folder) {
startFile = new File(folder);
startFile = new File(checkNotNull(folder, "folder"));
if (!startFile.exists()) {
throw new RuntimeException(folder + " not found");
}
return this;
}

public List<Violation> violations() {
List<File> includedFiles = findAllReports(startFile, pattern);
final List<File> includedFiles = findAllReports(startFile, pattern);
if (LOG.isLoggable(FINE)) {
LOG.log(FINE, "Found " + includedFiles.size() + " reports:");
for (File f : includedFiles) {
for (final File f : includedFiles) {
LOG.log(FINE, f.getAbsolutePath());
}
}
List<Violation> foundViolations = parser.findViolations(includedFiles);
boolean reporterWasSupplied =
final List<Violation> foundViolations = parser.findViolations(includedFiles);
final boolean reporterWasSupplied =
reporter != null && !reporter.trim().isEmpty() && !reporter.equals(parser.name());
if (reporterWasSupplied) {
setReporter(foundViolations, reporter);
}

if (LOG.isLoggable(FINE)) {
LOG.log(FINE, "Found " + foundViolations.size() + " violations:");
for (Violation v : foundViolations) {
for (final Violation v : foundViolations) {
LOG.log(
FINE,
v.getReporter()
Expand Down

0 comments on commit 2147659

Please sign in to comment.