From e390aaedcb7ec686668a244ceacd537c33aba911 Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Sun, 24 Dec 2017 12:24:05 +0100 Subject: [PATCH] Implementing reporter output --- CHANGELOG.md | 10 + build.gradle | 4 +- gradle.properties | 2 +- .../violations/lib/DetailedReportCreator.java | 13 ++ .../bjurr/violations/lib/ViolationsApi.java | 91 ++++++++ .../violations/lib/ViolationsReporterApi.java | 203 +++++++++++++----- .../lib/ViolationsReporterDetailLevel.java | 10 + .../bjurr/violations/lib/model/Violation.java | 13 +- .../bjurr/violations/lib/AndroidLintTest.java | 4 +- .../se/bjurr/violations/lib/CLangTest.java | 6 +- .../java/se/bjurr/violations/lib/CPDTest.java | 4 +- .../se/bjurr/violations/lib/CPPCheckTest.java | 4 +- .../se/bjurr/violations/lib/CSSLintTest.java | 4 +- .../bjurr/violations/lib/CheckstyleTest.java | 8 +- .../se/bjurr/violations/lib/CodeNarcTest.java | 4 +- .../se/bjurr/violations/lib/CppLintTest.java | 4 +- .../se/bjurr/violations/lib/DocFXTest.java | 4 +- .../se/bjurr/violations/lib/FindbugsTest.java | 6 +- .../se/bjurr/violations/lib/Flake8Test.java | 4 +- .../se/bjurr/violations/lib/FxCopTest.java | 4 +- .../se/bjurr/violations/lib/GendarmeTest.java | 6 +- .../se/bjurr/violations/lib/GoLintTest.java | 6 +- .../se/bjurr/violations/lib/JCReportTest.java | 4 +- .../se/bjurr/violations/lib/JSHintTest.java | 4 +- .../se/bjurr/violations/lib/KlocworkTest.java | 4 +- .../se/bjurr/violations/lib/LintTest.java | 4 +- .../se/bjurr/violations/lib/MyPyTest.java | 4 +- .../java/se/bjurr/violations/lib/PMDTest.java | 8 +- .../bjurr/violations/lib/PerlCriticTest.java | 8 +- .../se/bjurr/violations/lib/PiTestTest.java | 4 +- .../bjurr/violations/lib/PyDocStyleTest.java | 4 +- .../se/bjurr/violations/lib/PyLintTest.java | 4 +- .../bjurr/violations/lib/ResharperTest.java | 4 +- .../bjurr/violations/lib/SbtScalacTest.java | 4 +- .../se/bjurr/violations/lib/SimianTest.java | 4 +- .../se/bjurr/violations/lib/StyleCopTest.java | 4 +- .../lib/ViolationsReporterApiTest.java | 130 +++++++++++ .../se/bjurr/violations/lib/XMLLintTest.java | 4 +- .../se/bjurr/violations/lib/ZPTLintTest.java | 4 +- 39 files changed, 487 insertions(+), 129 deletions(-) create mode 100644 src/main/java/se/bjurr/violations/lib/DetailedReportCreator.java create mode 100644 src/main/java/se/bjurr/violations/lib/ViolationsApi.java create mode 100644 src/main/java/se/bjurr/violations/lib/ViolationsReporterDetailLevel.java create mode 100644 src/test/java/se/bjurr/violations/lib/ViolationsReporterApiTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d523d443..877a4826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ Changelog of Violations lib. +## 1.44 +### No issue + +**Packaging fat jar as main jar** + + * So that no special classifier is needed to get the relocated gson. + +[764fe8fd94835a4](https://github.com/tomasbjerre/violations-lib/commit/764fe8fd94835a4) Tomas Bjerre *2017-12-22 18:28:23* + + ## 1.43 ### No issue diff --git a/build.gradle b/build.gradle index 5ae6ed22..778711b7 100644 --- a/build.gradle +++ b/build.gradle @@ -21,10 +21,12 @@ apply from: project.buildscript.classLoader.getResource('release.gradle').toURI( dependencies { compile 'com.google.code.gson:gson:2.8.2' + compile 'com.jakewharton.fliptables:fliptables:1.0.2' testCompile 'junit:junit:4.12' testCompile 'org.assertj:assertj-core:2.3.0' } shadowJar { - relocate 'com.google', 'se.bjurr.com.google' + relocate 'com.google', project.group + '.com.google' + relocate 'com.jakewharton', project.group + '.com.jakewharton' } diff --git a/gradle.properties b/gradle.properties index a0e0a769..a6942546 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version = 1.45-SNAPSHOT +version = 1.46-SNAPSHOT diff --git a/src/main/java/se/bjurr/violations/lib/DetailedReportCreator.java b/src/main/java/se/bjurr/violations/lib/DetailedReportCreator.java new file mode 100644 index 00000000..f18df1d8 --- /dev/null +++ b/src/main/java/se/bjurr/violations/lib/DetailedReportCreator.java @@ -0,0 +1,13 @@ +package se.bjurr.violations.lib; + +import java.util.List; +import se.bjurr.violations.lib.model.Violation; + +class DetailedReportCreator { + + DetailedReportCreator(List violations) {} + + String create() { + return null; + } +} diff --git a/src/main/java/se/bjurr/violations/lib/ViolationsApi.java b/src/main/java/se/bjurr/violations/lib/ViolationsApi.java new file mode 100644 index 00000000..544778a7 --- /dev/null +++ b/src/main/java/se/bjurr/violations/lib/ViolationsApi.java @@ -0,0 +1,91 @@ +package se.bjurr.violations.lib; + +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; +import java.util.List; +import java.util.logging.Logger; +import se.bjurr.violations.lib.model.Violation; +import se.bjurr.violations.lib.reports.Parser; + +public class ViolationsApi { + private static Logger LOG = Logger.getLogger(ViolationsApi.class.getSimpleName()); + + private String pattern; + private Parser parser; + private File startFile; + private String reporter; + + public static String getDetailedReport(List violations) { + return new DetailedReportCreator(violations) // + .create(); + } + + public static ViolationsApi violationsApi() { + return new ViolationsApi(); + } + + private ViolationsApi() {} + + public ViolationsApi findAll(Parser parser) { + this.parser = checkNotNull(parser, "parser"); + return this; + } + + public ViolationsApi withReporter(String reporter) { + this.reporter = checkNotNull(reporter, "reporter"); + return this; + } + + public ViolationsApi inFolder(String folder) { + startFile = new File(checkNotNull(folder, "folder")); + if (!startFile.exists()) { + throw new RuntimeException(folder + " not found"); + } + return this; + } + + public List violations() { + final List includedFiles = findAllReports(startFile, pattern); + if (LOG.isLoggable(FINE)) { + LOG.log(FINE, "Found " + includedFiles.size() + " reports:"); + for (final File f : includedFiles) { + LOG.log(FINE, f.getAbsolutePath()); + } + } + final List 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 (final Violation v : foundViolations) { + LOG.log( + FINE, + v.getReporter() + + " " + + v.getSeverity() + + " (" + + v.getRule().or("?") + + ") " + + v.getFile() + + " " + + v.getStartLine() + + " -> " + + v.getEndLine()); + } + } + return foundViolations; + } + + public ViolationsApi withPattern(String regularExpression) { + pattern = regularExpression; + return this; + } +} diff --git a/src/main/java/se/bjurr/violations/lib/ViolationsReporterApi.java b/src/main/java/se/bjurr/violations/lib/ViolationsReporterApi.java index 27939505..fdc53e92 100644 --- a/src/main/java/se/bjurr/violations/lib/ViolationsReporterApi.java +++ b/src/main/java/se/bjurr/violations/lib/ViolationsReporterApi.java @@ -1,88 +1,181 @@ package se.bjurr.violations.lib; -import static java.util.logging.Level.FINE; -import static se.bjurr.violations.lib.reports.ReportsFinder.findAllReports; +import static se.bjurr.violations.lib.ViolationsReporterDetailLevel.COMPACT; +import static se.bjurr.violations.lib.ViolationsReporterDetailLevel.PER_FILE_COMPACT; +import static se.bjurr.violations.lib.ViolationsReporterDetailLevel.VERBOSE; +import static se.bjurr.violations.lib.model.SEVERITY.ERROR; +import static se.bjurr.violations.lib.model.SEVERITY.INFO; +import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.util.Utils.checkNotNull; -import static se.bjurr.violations.lib.util.Utils.setReporter; -import java.io.File; +import com.jakewharton.fliptables.FlipTable; +import java.util.ArrayList; import java.util.List; -import java.util.logging.Logger; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import se.bjurr.violations.lib.model.SEVERITY; import se.bjurr.violations.lib.model.Violation; -import se.bjurr.violations.lib.reports.Parser; public class ViolationsReporterApi { - private static Logger LOG = Logger.getLogger(ViolationsReporterApi.class.getSimpleName()); + + private Iterable violations; + + private ViolationsReporterApi() {} public static ViolationsReporterApi violationsReporterApi() { return new ViolationsReporterApi(); } - private String pattern; - private Parser parser; + public String getReport(ViolationsReporterDetailLevel level) { + checkNotNull(violations, "violations"); - private File startFile; + final StringBuilder sb = new StringBuilder(); - private String reporter; + if (level == COMPACT) { + sb.append(toCompact(violations, "Summary")); + } else if (level == PER_FILE_COMPACT) { + sb.append(toPerFile(violations)); + sb.append(toCompact(violations, "Summary")); + } else if (level == VERBOSE) { + sb.append(toVerbose(violations)); + sb.append(toCompact(violations, "Summary")); + } - private ViolationsReporterApi() {} + return sb.toString(); + } - public ViolationsReporterApi findAll(Parser parser) { - this.parser = checkNotNull(parser, "parser"); - return this; + private StringBuilder toVerbose(Iterable violations) { + final StringBuilder sb = new StringBuilder(); + final Map> perFile = getViolationsPerFile(violations); + for (final String file : perFile.keySet()) { + sb.append(file + "\n"); + sb.append(toDetailed(perFile.get(file), "Summary of " + file)); + sb.append("\n"); + } + return sb; } - public ViolationsReporterApi withReporter(String reporter) { - this.reporter = checkNotNull(reporter, "reporter"); + private StringBuilder toPerFile(Iterable violations) { + final StringBuilder sb = new StringBuilder(); + final Map> perFile = getViolationsPerFile(violations); + for (final String file : perFile.keySet()) { + sb.append(toCompact(perFile.get(file), "Summary of " + file)); + sb.append("\n"); + } + return sb; + } + + public ViolationsReporterApi withViolations(List violations) { + this.violations = violations; return this; } - public ViolationsReporterApi inFolder(String folder) { - startFile = new File(checkNotNull(folder, "folder")); - if (!startFile.exists()) { - throw new RuntimeException(folder + " not found"); + private StringBuilder toDetailed(Iterable violations, String summarySubject) { + final StringBuilder sb = new StringBuilder(); + final List rows = new ArrayList<>(); + for (final Violation violation : violations) { + final String[] row = { + violation.getReporter(), + violation.getRule().or(""), + violation.getSeverity().name(), + violation.getStartLine().toString(), + violation.getMessage() + }; + rows.add(row); } - return this; + + final String[] headers = {"Reporter", "Rule", "Severity", "Line", "Message"}; + + final String[][] data = rows.toArray(new String[][] {}); + sb.append(FlipTable.of(headers, data)); + sb.append("\n"); + sb.append(toCompact(violations, summarySubject)); + sb.append("\n"); + return sb; } - public List violations() { - final List includedFiles = findAllReports(startFile, pattern); - if (LOG.isLoggable(FINE)) { - LOG.log(FINE, "Found " + includedFiles.size() + " reports:"); - for (final File f : includedFiles) { - LOG.log(FINE, f.getAbsolutePath()); - } + private StringBuilder toCompact(Iterable violations, String subject) { + final StringBuilder sb = new StringBuilder(); + final Map> perReporter = getViolationsPerReporter(violations); + final List rows = new ArrayList<>(); + + Integer totNumInfo = 0; + Integer totNumWarn = 0; + Integer totNumError = 0; + Integer totNumTot = 0; + + for (final String reporter : perReporter.keySet()) { + final Map> perSeverity = + getViolationsPerSeverity(perReporter.get(reporter)); + final Integer numInfo = perSeverity.get(INFO).size(); + final Integer numWarn = perSeverity.get(WARN).size(); + final Integer numError = perSeverity.get(ERROR).size(); + final Integer numTot = numInfo + numWarn + numError; + final String[] row = { + reporter, numInfo.toString(), numWarn.toString(), numError.toString(), numTot.toString() + }; + rows.add(row); + + totNumInfo += numInfo; + totNumWarn += numWarn; + totNumError += numError; + totNumTot += numTot; } - final List foundViolations = parser.findViolations(includedFiles); - final boolean reporterWasSupplied = - reporter != null && !reporter.trim().isEmpty() && !reporter.equals(parser.name()); - if (reporterWasSupplied) { - setReporter(foundViolations, reporter); + final String[] row = { + "", totNumInfo.toString(), totNumWarn.toString(), totNumError.toString(), totNumTot.toString() + }; + rows.add(row); + + final String[] headers = {"Reporter", INFO.name(), WARN.name(), ERROR.name(), "Total"}; + + final String[][] data = rows.toArray(new String[][] {}); + sb.append(subject + "\n"); + sb.append(FlipTable.of(headers, data)); + return sb; + } + + private Map> getViolationsPerSeverity(Set violations) { + final Map> violationsPerSeverity = new TreeMap<>(); + for (final SEVERITY severity : SEVERITY.values()) { + violationsPerSeverity.put(severity, new TreeSet()); } - if (LOG.isLoggable(FINE)) { - LOG.log(FINE, "Found " + foundViolations.size() + " violations:"); - for (final Violation v : foundViolations) { - LOG.log( - FINE, - v.getReporter() - + " " - + v.getSeverity() - + " (" - + v.getRule().or("?") - + ") " - + v.getFile() - + " " - + v.getStartLine() - + " -> " - + v.getEndLine()); - } + for (final Violation violation : violations) { + final Set perReporter = + getOrCreate(violationsPerSeverity, violation.getSeverity()); + perReporter.add(violation); } - return foundViolations; + return violationsPerSeverity; } - public ViolationsReporterApi withPattern(String regularExpression) { - pattern = regularExpression; - return this; + private Map> getViolationsPerFile(Iterable violations) { + final Map> violationsPerFile = new TreeMap<>(); + for (final Violation violation : violations) { + final Set perReporter = getOrCreate(violationsPerFile, violation.getFile()); + perReporter.add(violation); + } + return violationsPerFile; + } + + private Map> getViolationsPerReporter(Iterable violations) { + final Map> violationsPerReporter = new TreeMap<>(); + for (final Violation violation : violations) { + final Set perReporter = + getOrCreate(violationsPerReporter, violation.getReporter()); + perReporter.add(violation); + } + return violationsPerReporter; + } + + private Set getOrCreate(Map> container, K key) { + if (container.containsKey(key)) { + return container.get(key); + } else { + final Set violationList = new TreeSet<>(); + container.put(key, violationList); + return violationList; + } } } diff --git a/src/main/java/se/bjurr/violations/lib/ViolationsReporterDetailLevel.java b/src/main/java/se/bjurr/violations/lib/ViolationsReporterDetailLevel.java new file mode 100644 index 00000000..b3396130 --- /dev/null +++ b/src/main/java/se/bjurr/violations/lib/ViolationsReporterDetailLevel.java @@ -0,0 +1,10 @@ +package se.bjurr.violations.lib; + +public enum ViolationsReporterDetailLevel { + /** Show detailed violations per file. */ + VERBOSE, + /** Show number of violations. Per reporter and in total. */ + COMPACT, + /** Like compact but per file. */ + PER_FILE_COMPACT +} diff --git a/src/main/java/se/bjurr/violations/lib/model/Violation.java b/src/main/java/se/bjurr/violations/lib/model/Violation.java index 4b949d42..5443fd3f 100644 --- a/src/main/java/se/bjurr/violations/lib/model/Violation.java +++ b/src/main/java/se/bjurr/violations/lib/model/Violation.java @@ -11,7 +11,7 @@ import se.bjurr.violations.lib.reports.Parser; import se.bjurr.violations.lib.util.Optional; -public class Violation implements Serializable { +public class Violation implements Serializable, Comparable { public static class ViolationBuilder { private Integer column; @@ -164,7 +164,7 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) { return false; } - Violation other = (Violation) obj; + final Violation other = (Violation) obj; if (column == null) { if (other.column != null) { return false; @@ -333,4 +333,13 @@ public String toString() { + startLine + "]"; } + + @Override + public int compareTo(Violation o) { + return comparingString(this).compareTo(comparingString(o)); + } + + private String comparingString(Violation o) { + return o.file + "_" + o.getStartLine() + "_" + o.getParser() + "_" + o.getMessage(); + } } diff --git a/src/test/java/se/bjurr/violations/lib/AndroidLintTest.java b/src/test/java/se/bjurr/violations/lib/AndroidLintTest.java index ddf538ba..7288e548 100644 --- a/src/test/java/se/bjurr/violations/lib/AndroidLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/AndroidLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.model.Violation.violationBuilder; @@ -21,7 +21,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/androidlint/.*\\.xml$") // .inFolder(rootFolder) // .findAll(ANDROIDLINT) // diff --git a/src/test/java/se/bjurr/violations/lib/CLangTest.java b/src/test/java/se/bjurr/violations/lib/CLangTest.java index 3e227cc0..f4470979 100644 --- a/src/test/java/se/bjurr/violations/lib/CLangTest.java +++ b/src/test/java/se/bjurr/violations/lib/CLangTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.model.SEVERITY.WARN; @@ -19,7 +19,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/clang/clang.*\\.txt$") // .inFolder(rootFolder) // .findAll(CLANG) // @@ -56,7 +56,7 @@ public void testThatRubycopViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/clang/rubycop\\.txt$") // .inFolder(rootFolder) // .findAll(CLANG) // diff --git a/src/test/java/se/bjurr/violations/lib/CPDTest.java b/src/test/java/se/bjurr/violations/lib/CPDTest.java index 09acf096..19a04d12 100644 --- a/src/test/java/se/bjurr/violations/lib/CPDTest.java +++ b/src/test/java/se/bjurr/violations/lib/CPDTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.CPD; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/cpd/.*\\.xml$") // .inFolder(rootFolder) // .findAll(CPD) // diff --git a/src/test/java/se/bjurr/violations/lib/CPPCheckTest.java b/src/test/java/se/bjurr/violations/lib/CPPCheckTest.java index 8804f2f4..b7d26fc9 100644 --- a/src/test/java/se/bjurr/violations/lib/CPPCheckTest.java +++ b/src/test/java/se/bjurr/violations/lib/CPPCheckTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.model.Violation.violationBuilder; @@ -24,7 +24,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/cppcheck/.*\\.xml$") // .inFolder(rootFolder) // .findAll(CPPCHECK) // diff --git a/src/test/java/se/bjurr/violations/lib/CSSLintTest.java b/src/test/java/se/bjurr/violations/lib/CSSLintTest.java index d097e30a..76c307bd 100644 --- a/src/test/java/se/bjurr/violations/lib/CSSLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/CSSLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.model.Violation.violationBuilder; import static se.bjurr.violations.lib.reports.Parser.CSSLINT; @@ -18,7 +18,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/csslint/.*\\.xml$") // .inFolder(rootFolder) // .findAll(CSSLINT) // diff --git a/src/test/java/se/bjurr/violations/lib/CheckstyleTest.java b/src/test/java/se/bjurr/violations/lib/CheckstyleTest.java index a878bbd4..9b9e42ac 100644 --- a/src/test/java/se/bjurr/violations/lib/CheckstyleTest.java +++ b/src/test/java/se/bjurr/violations/lib/CheckstyleTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.model.SEVERITY.WARN; @@ -20,7 +20,7 @@ public void testThatViolationsCanBeParsed() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/checkstyle/main\\.xml$") // .inFolder(rootFolder) // .findAll(CHECKSTYLE) // @@ -82,7 +82,7 @@ public void testThatPHPViolationsCanBeParsed() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/checkstyle/phpcheckstyle\\.xml$") // .inFolder(rootFolder) // .findAll(CHECKSTYLE) // @@ -103,7 +103,7 @@ public void testThatPHPViolationsCanBeParsedIfNoSource() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/checkstyle/checkstyle-no-source\\.xml$") // .inFolder(rootFolder) // .findAll(CHECKSTYLE) // diff --git a/src/test/java/se/bjurr/violations/lib/CodeNarcTest.java b/src/test/java/se/bjurr/violations/lib/CodeNarcTest.java index e66ac295..8e3512cc 100644 --- a/src/test/java/se/bjurr/violations/lib/CodeNarcTest.java +++ b/src/test/java/se/bjurr/violations/lib/CodeNarcTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.CODENARC; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/codenarc/.*\\.xml$") // .inFolder(rootFolder) // .findAll(CODENARC) // diff --git a/src/test/java/se/bjurr/violations/lib/CppLintTest.java b/src/test/java/se/bjurr/violations/lib/CppLintTest.java index 5469d503..bfd83fa6 100644 --- a/src/test/java/se/bjurr/violations/lib/CppLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/CppLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.reports.Parser.CPPLINT; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/cpplint/.*\\.txt$") // .inFolder(rootFolder) // .findAll(CPPLINT) // diff --git a/src/test/java/se/bjurr/violations/lib/DocFXTest.java b/src/test/java/se/bjurr/violations/lib/DocFXTest.java index 65bb8024..19e361b1 100644 --- a/src/test/java/se/bjurr/violations/lib/DocFXTest.java +++ b/src/test/java/se/bjurr/violations/lib/DocFXTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.DOCFX; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/docfx/.*\\.json$") // .inFolder(rootFolder) // .findAll(DOCFX) // diff --git a/src/test/java/se/bjurr/violations/lib/FindbugsTest.java b/src/test/java/se/bjurr/violations/lib/FindbugsTest.java index cbbead55..0413c58a 100644 --- a/src/test/java/se/bjurr/violations/lib/FindbugsTest.java +++ b/src/test/java/se/bjurr/violations/lib/FindbugsTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.filterRule; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.parsers.FindbugsParser.FINDBUGS_SPECIFIC_RANK; import static se.bjurr.violations.lib.reports.Parser.FINDBUGS; @@ -21,7 +21,7 @@ public class FindbugsTest { public void before() { String rootFolder = getRootFolder(); actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/findbugs/main\\.xml$") // .inFolder(rootFolder) // .findAll(FINDBUGS) // @@ -35,7 +35,7 @@ public void before() { public void testMavenGeneratedFindbugs() { String rootFolder = getRootFolder(); List maven = - violationsReporterApi() // + violationsApi() // .withPattern(".*/findbugs/fromMaven.xml$") // .inFolder(rootFolder) // .findAll(FINDBUGS) // diff --git a/src/test/java/se/bjurr/violations/lib/Flake8Test.java b/src/test/java/se/bjurr/violations/lib/Flake8Test.java index 8e0d2459..10acb884 100644 --- a/src/test/java/se/bjurr/violations/lib/Flake8Test.java +++ b/src/test/java/se/bjurr/violations/lib/Flake8Test.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.model.SEVERITY.WARN; @@ -20,7 +20,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/flake8/.*\\.txt$") // .inFolder(rootFolder) // .findAll(FLAKE8) // diff --git a/src/test/java/se/bjurr/violations/lib/FxCopTest.java b/src/test/java/se/bjurr/violations/lib/FxCopTest.java index 2218724a..1c7a7660 100644 --- a/src/test/java/se/bjurr/violations/lib/FxCopTest.java +++ b/src/test/java/se/bjurr/violations/lib/FxCopTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.FXCOP; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/fxcop/.*\\.xml$") // .inFolder(rootFolder) // .findAll(FXCOP) // diff --git a/src/test/java/se/bjurr/violations/lib/GendarmeTest.java b/src/test/java/se/bjurr/violations/lib/GendarmeTest.java index d7127990..58807389 100644 --- a/src/test/java/se/bjurr/violations/lib/GendarmeTest.java +++ b/src/test/java/se/bjurr/violations/lib/GendarmeTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.GENDARME; @@ -16,7 +16,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/gendarme/.*\\.xml$") // .inFolder(rootFolder) // .findAll(GENDARME) // @@ -47,7 +47,7 @@ public void testThatViolationsCanBeParsedGendarmeUnix() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/gendarme/Gendarme_unix\\.xml$") // .inFolder(rootFolder) // .findAll(GENDARME) // diff --git a/src/test/java/se/bjurr/violations/lib/GoLintTest.java b/src/test/java/se/bjurr/violations/lib/GoLintTest.java index e91ade8a..04bfe21e 100644 --- a/src/test/java/se/bjurr/violations/lib/GoLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/GoLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.GOLINT; @@ -18,7 +18,7 @@ public void testThatGoLintViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/golint/golint\\.txt$") // .inFolder(rootFolder) // .findAll(GOLINT) // @@ -60,7 +60,7 @@ public void testThatGoVetViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/golint/govet\\.txt$") // .inFolder(rootFolder) // .findAll(GOLINT) // diff --git a/src/test/java/se/bjurr/violations/lib/JCReportTest.java b/src/test/java/se/bjurr/violations/lib/JCReportTest.java index 7c7a87b9..ecfd8b88 100644 --- a/src/test/java/se/bjurr/violations/lib/JCReportTest.java +++ b/src/test/java/se/bjurr/violations/lib/JCReportTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.JCREPORT; @@ -16,7 +16,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/jcreport/.*\\.xml$") // .inFolder(rootFolder) // .findAll(JCREPORT) // diff --git a/src/test/java/se/bjurr/violations/lib/JSHintTest.java b/src/test/java/se/bjurr/violations/lib/JSHintTest.java index 95f3b573..f4bcf5b8 100644 --- a/src/test/java/se/bjurr/violations/lib/JSHintTest.java +++ b/src/test/java/se/bjurr/violations/lib/JSHintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.JSHINT; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/jshint/.*\\.xml$") // .inFolder(rootFolder) // .findAll(JSHINT) // diff --git a/src/test/java/se/bjurr/violations/lib/KlocworkTest.java b/src/test/java/se/bjurr/violations/lib/KlocworkTest.java index 0eabc07d..b29d2877 100644 --- a/src/test/java/se/bjurr/violations/lib/KlocworkTest.java +++ b/src/test/java/se/bjurr/violations/lib/KlocworkTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.KLOCWORK; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/klocwork/.*\\.xml$") // .inFolder(rootFolder) // .findAll(KLOCWORK) // diff --git a/src/test/java/se/bjurr/violations/lib/LintTest.java b/src/test/java/se/bjurr/violations/lib/LintTest.java index 067d7907..3738cb4d 100644 --- a/src/test/java/se/bjurr/violations/lib/LintTest.java +++ b/src/test/java/se/bjurr/violations/lib/LintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.model.Violation.violationBuilder; import static se.bjurr.violations.lib.reports.Parser.LINT; @@ -18,7 +18,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/lint/.*\\.xml$") // .inFolder(rootFolder) // .findAll(LINT) // diff --git a/src/test/java/se/bjurr/violations/lib/MyPyTest.java b/src/test/java/se/bjurr/violations/lib/MyPyTest.java index 667959c7..6b413093 100644 --- a/src/test/java/se/bjurr/violations/lib/MyPyTest.java +++ b/src/test/java/se/bjurr/violations/lib/MyPyTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.Violation.violationBuilder; import static se.bjurr.violations.lib.reports.Parser.MYPY; @@ -20,7 +20,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/mypy/.*\\.txt$") // .inFolder(rootFolder) // .findAll(MYPY) // diff --git a/src/test/java/se/bjurr/violations/lib/PMDTest.java b/src/test/java/se/bjurr/violations/lib/PMDTest.java index 6004c5e7..d88ea7b5 100644 --- a/src/test/java/se/bjurr/violations/lib/PMDTest.java +++ b/src/test/java/se/bjurr/violations/lib/PMDTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.PMD; @@ -18,7 +18,7 @@ public void testThatViolationsCanBeParsed() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/pmd/main\\.xml$") // .inFolder(rootFolder) // .findAll(PMD) // @@ -48,7 +48,7 @@ public void testThatViolationsCanBeParsedIfNoRuleset() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/pmd/no-ruleset\\.xml$") // .inFolder(rootFolder) // .findAll(PMD) // @@ -79,7 +79,7 @@ public void testThatPHPMDViolationsCanBeParsed() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/pmd/phpmd\\.xml$") // .inFolder(rootFolder) // .findAll(PMD) // diff --git a/src/test/java/se/bjurr/violations/lib/PerlCriticTest.java b/src/test/java/se/bjurr/violations/lib/PerlCriticTest.java index 23fd1260..40c2708e 100644 --- a/src/test/java/se/bjurr/violations/lib/PerlCriticTest.java +++ b/src/test/java/se/bjurr/violations/lib/PerlCriticTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.PERLCRITIC; @@ -15,10 +15,10 @@ public class PerlCriticTest { @Test public void testThatViolationsCanBeParsed() { - String rootFolder = getRootFolder(); + final String rootFolder = getRootFolder(); - List actual = - violationsReporterApi() // + final List actual = + violationsApi() // .withPattern(".*/perlcritic/.*\\.txt$") // .inFolder(rootFolder) // .findAll(PERLCRITIC) // diff --git a/src/test/java/se/bjurr/violations/lib/PiTestTest.java b/src/test/java/se/bjurr/violations/lib/PiTestTest.java index 75b25a8a..8340a192 100644 --- a/src/test/java/se/bjurr/violations/lib/PiTestTest.java +++ b/src/test/java/se/bjurr/violations/lib/PiTestTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.PITEST; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/pitest/.*\\.xml$") // .inFolder(rootFolder) // .findAll(PITEST) // diff --git a/src/test/java/se/bjurr/violations/lib/PyDocStyleTest.java b/src/test/java/se/bjurr/violations/lib/PyDocStyleTest.java index 04692344..89d4c13f 100644 --- a/src/test/java/se/bjurr/violations/lib/PyDocStyleTest.java +++ b/src/test/java/se/bjurr/violations/lib/PyDocStyleTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.Violation.violationBuilder; import static se.bjurr.violations.lib.reports.Parser.PYDOCSTYLE; @@ -20,7 +20,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/pydocstyle/.*\\.txt$") // .inFolder(rootFolder) // .findAll(PYDOCSTYLE) // diff --git a/src/test/java/se/bjurr/violations/lib/PyLintTest.java b/src/test/java/se/bjurr/violations/lib/PyLintTest.java index f29bcbe3..83aba55a 100644 --- a/src/test/java/se/bjurr/violations/lib/PyLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/PyLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.PYLINT; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { final String rootFolder = getRootFolder(); final List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/pylint/.*\\.txt$") // .inFolder(rootFolder) // .findAll(PYLINT) // diff --git a/src/test/java/se/bjurr/violations/lib/ResharperTest.java b/src/test/java/se/bjurr/violations/lib/ResharperTest.java index 9addc0c5..7573c53e 100644 --- a/src/test/java/se/bjurr/violations/lib/ResharperTest.java +++ b/src/test/java/se/bjurr/violations/lib/ResharperTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.model.SEVERITY.WARN; @@ -19,7 +19,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/resharper/.*\\.xml$") // .inFolder(rootFolder) // .findAll(RESHARPER) // diff --git a/src/test/java/se/bjurr/violations/lib/SbtScalacTest.java b/src/test/java/se/bjurr/violations/lib/SbtScalacTest.java index f31d9493..1829a9d3 100644 --- a/src/test/java/se/bjurr/violations/lib/SbtScalacTest.java +++ b/src/test/java/se/bjurr/violations/lib/SbtScalacTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.*; import static se.bjurr.violations.lib.model.Violation.violationBuilder; import static se.bjurr.violations.lib.reports.Parser.SBTSCALAC; @@ -18,7 +18,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/sbtscalac/sbtscalac\\.txt$") // .inFolder(rootFolder) // .findAll(SBTSCALAC) // diff --git a/src/test/java/se/bjurr/violations/lib/SimianTest.java b/src/test/java/se/bjurr/violations/lib/SimianTest.java index ffb39b71..5b9c8a67 100644 --- a/src/test/java/se/bjurr/violations/lib/SimianTest.java +++ b/src/test/java/se/bjurr/violations/lib/SimianTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.SIMIAN; @@ -16,7 +16,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/simian/.*\\.xml$") // .inFolder(rootFolder) // .findAll(SIMIAN) // diff --git a/src/test/java/se/bjurr/violations/lib/StyleCopTest.java b/src/test/java/se/bjurr/violations/lib/StyleCopTest.java index c10b4411..a074df70 100644 --- a/src/test/java/se/bjurr/violations/lib/StyleCopTest.java +++ b/src/test/java/se/bjurr/violations/lib/StyleCopTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import static se.bjurr.violations.lib.reports.Parser.STYLECOP; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/stylecop/.*\\.xml$") // .inFolder(rootFolder) // .findAll(STYLECOP) // diff --git a/src/test/java/se/bjurr/violations/lib/ViolationsReporterApiTest.java b/src/test/java/se/bjurr/violations/lib/ViolationsReporterApiTest.java new file mode 100644 index 00000000..91df8f01 --- /dev/null +++ b/src/test/java/se/bjurr/violations/lib/ViolationsReporterApiTest.java @@ -0,0 +1,130 @@ +package se.bjurr.violations.lib; + +import static se.bjurr.violations.lib.TestUtils.getRootFolder; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; +import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsReporterDetailLevel.COMPACT; +import static se.bjurr.violations.lib.ViolationsReporterDetailLevel.PER_FILE_COMPACT; +import static se.bjurr.violations.lib.ViolationsReporterDetailLevel.VERBOSE; +import static se.bjurr.violations.lib.reports.Parser.FINDBUGS; +import static se.bjurr.violations.lib.reports.Parser.PERLCRITIC; +import static se.bjurr.violations.lib.reports.Parser.PMD; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import se.bjurr.violations.lib.model.Violation; + +public class ViolationsReporterApiTest { + + private static Logger LOG = Logger.getLogger(ViolationsReporterApiTest.class.getName()); + + private List findbugsViolations; + private List pmdViolations; + private final List accumulatedViolations = new ArrayList<>(); + private List perlCriticViolations; + + @Rule public TestName name = new TestName(); + + @Before + public void before() { + final String rootFolder = getRootFolder(); + + findbugsViolations = + violationsApi() // + .withPattern(".*/findbugs/main\\.xml$") // + .inFolder(rootFolder) // + .findAll(FINDBUGS) // + .violations(); + accumulatedViolations.addAll(findbugsViolations); + + pmdViolations = + violationsApi() // + .withPattern(".*/pmd/main\\.xml$") // + .inFolder(rootFolder) // + .findAll(PMD) // + .violations(); + + pmdViolations = + violationsApi() // + .withPattern(".*/pmd/main\\.xml$") // + .inFolder(rootFolder) // + .findAll(PMD) // + .violations(); + accumulatedViolations.addAll(pmdViolations); + + perlCriticViolations = + violationsApi() // + .withPattern(".*/perlcritic/.*\\.txt$") // + .inFolder(rootFolder) // + .findAll(PERLCRITIC) // + .violations(); + accumulatedViolations.addAll(perlCriticViolations); + + LOG.info("\n\n\n " + this.name.getMethodName() + " \n\n\n"); + } + + @Test + public void testCompact() { + final String report = + violationsReporterApi() // + .withViolations(accumulatedViolations) // + .getReport(COMPACT); + + LOG.info("\n" + report); + } + + @Test + public void testPerFileCompact() { + final String report = + violationsReporterApi() // + .withViolations(accumulatedViolations) // + .getReport(PER_FILE_COMPACT); + + LOG.info("\n" + report); + } + + @Test + public void testVerbose() { + final String report = + violationsReporterApi() // + .withViolations(accumulatedViolations) // + .getReport(VERBOSE); + + LOG.info("\n" + report); + } + + @Test + public void testCompactWithZeroViolations() { + final String report = + violationsReporterApi() // + .withViolations(new ArrayList()) // + .getReport(COMPACT); + + LOG.info("\n" + report); + } + + @Test + public void testPerFileCompactWithZeroViolations() { + final String report = + violationsReporterApi() // + .withViolations(new ArrayList()) // + .getReport(PER_FILE_COMPACT); + + LOG.info("\n" + report); + } + + @Test + public void testVerboseWithZeroViolations() { + final String report = + violationsReporterApi() // + .withViolations(new ArrayList()) // + .getReport(VERBOSE); + + LOG.info("\n" + report); + } +} diff --git a/src/test/java/se/bjurr/violations/lib/XMLLintTest.java b/src/test/java/se/bjurr/violations/lib/XMLLintTest.java index ad673549..c40f457a 100644 --- a/src/test/java/se/bjurr/violations/lib/XMLLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/XMLLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.reports.Parser.XMLLINT; @@ -17,7 +17,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/xmllint/.*\\.txt$") // .inFolder(rootFolder) // .findAll(XMLLINT) // diff --git a/src/test/java/se/bjurr/violations/lib/ZPTLintTest.java b/src/test/java/se/bjurr/violations/lib/ZPTLintTest.java index 227eda6f..05f9aac9 100644 --- a/src/test/java/se/bjurr/violations/lib/ZPTLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/ZPTLintTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static se.bjurr.violations.lib.TestUtils.getRootFolder; -import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; +import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; import static se.bjurr.violations.lib.reports.Parser.ZPTLINT; @@ -16,7 +16,7 @@ public void testThatViolationsCanBeParsed() { String rootFolder = getRootFolder(); List actual = - violationsReporterApi() // + violationsApi() // .withPattern(".*/zptlint/.*\\.log$") // .inFolder(rootFolder) // .findAll(ZPTLINT) //