Skip to content

Commit

Permalink
Merge pull request #481 from jenkinsci/dependabot/maven/se.bjurr.viol…
Browse files Browse the repository at this point in the history
…ations-violations-lib-1.121

Bump violations-lib from 1.118 to 1.121
  • Loading branch information
uhafner authored Aug 19, 2020
2 parents bb0de35 + 2fbd9e3 commit 6a76b56
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 74 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<spotbugs.parser.library.version>6.0.4</spotbugs.parser.library.version>
<j2html.version>1.4.0</j2html.version>
<slf4j.version>1.7.30</slf4j.version>
<violations-lib.version>1.118</violations-lib.version>
<violations-lib.version>1.121</violations-lib.version>
<json.version>20200518</json.version>

<argLine>-Djava.util.logging.config.file=logging.properties</argLine>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.hm.hafner.analysis.parser.violations;

import java.util.List;
import java.util.Set;
import java.util.logging.Level;

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
Expand All @@ -11,6 +12,7 @@
import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.analysis.Severity;

import se.bjurr.violations.lib.ViolationsLogger;
import se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.parsers.ViolationsParser;
Expand All @@ -30,7 +32,7 @@ public Report parse(final ReaderFactory readerFactory)
throws ParsingCanceledException, ParsingException {
try {
ViolationsParser parser = createParser();
List<Violation> violations = parser.parseReportOutput(readerFactory.readString());
Set<Violation> violations = parser.parseReportOutput(readerFactory.readString(), new NullViolationsLogger());
return convertToReport(violations);
}
catch (Exception exception) {
Expand All @@ -53,7 +55,7 @@ public Report parse(final ReaderFactory readerFactory)
*
* @return the report
*/
Report convertToReport(final List<Violation> violations) {
Report convertToReport(final Set<Violation> violations) {
Report report = new Report();
for (Violation violation : violations) {
if (isValid(violation)) {
Expand Down Expand Up @@ -136,7 +138,6 @@ void extractAdditionalProperties(final IssueBuilder builder, final Violation vio
*
* @return the {@link Severity}
*/
@SuppressWarnings("unused")
Severity convertSeverity(final SEVERITY severity, final Violation violation) {
if (severity == SEVERITY.ERROR) {
return Severity.WARNING_HIGH;
Expand All @@ -146,4 +147,19 @@ Severity convertSeverity(final SEVERITY severity, final Violation violation) {
}
return Severity.WARNING_LOW;
}

/**
* A logger that does nothing.
*/
private static class NullViolationsLogger implements ViolationsLogger {
@Override
public void log(final Level level, final String s) {
// do not log anything
}

@Override
public void log(final Level level, final String s, final Throwable throwable) {
// do not log anything
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import edu.hm.hafner.analysis.IssueBuilder;
Expand All @@ -27,7 +28,7 @@ CPPCheckParser createParser() {
}

@Override
Report convertToReport(final List<Violation> violations) {
Report convertToReport(final Set<Violation> violations) {
Map<String, List<Violation>> violationsPerGroup =
new LinkedHashSet<>(violations).stream().collect(Collectors.groupingBy(Violation::getGroup));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ class AndroidLintParserAdapterTest extends AbstractParserTest {
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(2);
softly.assertThat(report.get(0))
.hasFileName("app/src/main/res/layout/fragment_main.xml")
.hasCategory("Correctness")
.hasLineStart(10)
.hasLineEnd(10)
.hasColumnStart(9)
.hasColumnEnd(9)
.hasSeverity(Severity.WARNING_NORMAL);
softly.assertThat(report.get(0).getMessage()).contains("ScrollView size validation");
softly.assertThat(report.get(1))
.hasFileName(
".gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.4.0/5b72bf48563ea8410e650de14aa33ff69a3e8c35/okio-1.4.0.jar")
.hasCategory("Correctness")
Expand All @@ -36,7 +27,16 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti
.hasColumnStart(0)
.hasColumnEnd(0)
.hasSeverity(Severity.WARNING_HIGH);
softly.assertThat(report.get(1).getMessage()).contains("Package not included in Android");
softly.assertThat(report.get(0).getMessage()).contains("Package not included in Android");
softly.assertThat(report.get(1))
.hasFileName("app/src/main/res/layout/fragment_main.xml")
.hasCategory("Correctness")
.hasLineStart(10)
.hasLineEnd(10)
.hasColumnStart(9)
.hasColumnEnd(9)
.hasSeverity(Severity.WARNING_NORMAL);
softly.assertThat(report.get(1).getMessage()).contains("ScrollView size validation");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CodeNarcAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(11);
softly.assertThat(report.get(0))
softly.assertThat(report.get(6))
.hasMessage("In most cases, exceptions should not be caught and ignored (swallowed).")
.hasFileName("foo/bar/Test.groovy")
.hasType("EmptyCatchBlock")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ void shouldFindMultipleLocationsWithSameId() {

assertThat(report).hasSize(2);

assertThat(report.get(0)).hasFileName(
"apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp")
assertThat(report.get(0))
.hasFileName("apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp")
.hasLineStart(53)
.hasMessage("Variable 'it' is reassigned a value before the old one has been used.")
.hasType("redundantAssignment");
assertThat(report.get(0).getLineRanges()).isEqualTo(new LineRangeList(new LineRange(51)));

assertThat(report.get(1)).hasFileName(
"that/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp")
.hasLineStart(51)
assertThat(report.get(1))
.hasFileName("that/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp")
.hasLineStart(53)
.hasMessage("Variable 'that' is reassigned a value before the old one has been used.")
.hasType("redundantAssignment");
assertThat(report.get(1).getLineRanges()).isEqualTo(new LineRangeList(new LineRange(53)));
assertThat(report.get(1).getLineRanges()).isEqualTo(new LineRangeList(new LineRange(51)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ class DocFxAdapterTest extends AbstractParserTest {
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(3);
softly.assertThat(report.get(0))
.hasMessage("Invalid file link:(~/missing.md#mobiilisovellus).")
.hasFileName("sanasto.md")
.hasType("InvalidFileLink")
.hasLineStart(63)
.hasSeverity(Severity.WARNING_NORMAL);
softly.assertThat(report.get(1))
.hasMessage("Invalid file link:(~/mobiilirajapinta/puuttuu.md).")
.hasFileName("mobiilirajapinta/json-dateandtime.md")
.hasType("InvalidFileLink")
.hasLineStart(18)
.hasSeverity(Severity.WARNING_NORMAL);
softly.assertThat(report.get(2))
softly.assertThat(report.get(1))
.hasMessage("Invalid file link:(~/mobiilirajapinta/joopajoo.md).")
.hasFileName("mobiilirajapinta/json-nimeämiskäytäntö.md")
.hasType("InvalidFileLink")
.hasLineStart(7)
.hasSeverity(Severity.WARNING_NORMAL);
softly.assertThat(report.get(2))
.hasMessage("Invalid file link:(~/missing.md#mobiilisovellus).")
.hasFileName("sanasto.md")
.hasType("InvalidFileLink")
.hasLineStart(63)
.hasSeverity(Severity.WARNING_NORMAL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Flake8AdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(12);
softly.assertThat(report.get(0))
softly.assertThat(report.get(3))
.hasMessage("'db' imported but unused")
.hasFileName("myproject/__init__.py")
.hasType("F401")
Expand All @@ -45,7 +45,7 @@ void shouldParseFileWithColumns() {
Report report = parse("flake8-issue53786");

assertThat(report).hasSize(9);
assertThat(report.get(0)).hasFileName("../devopsloft/application.py")
assertThat(report.get(8)).hasFileName("../devopsloft/application.py")
.hasLineStart(42)
.hasColumnStart(1)
.hasType("E302")
Expand All @@ -59,15 +59,15 @@ void shouldParseWithCurrentDirPrefix() {
assertThat(report).hasSize(2);
try (SoftAssertions softly = new SoftAssertions()) {
softly.assertThat(report.get(0)).hasFileName("./src/init.py")
.hasLineStart(66)
.hasColumnStart(121)
.hasType("E501")
.hasMessage("line too long (143 > 120 characters)");
softly.assertThat(report.get(1)).hasFileName("./src/init.py")
.hasLineStart(254)
.hasColumnStart(58)
.hasType("W292")
.hasMessage("no newline at end of file");
softly.assertThat(report.get(1)).hasFileName("./src/init.py")
.hasLineStart(66)
.hasColumnStart(121)
.hasType("E501")
.hasMessage("line too long (143 > 120 characters)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JsHintAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(6);
softly.assertThat(report.get(0))
softly.assertThat(report.get(2))
.hasMessage("Use '===' to compare with 'null'.: if (a == null)")
.hasFileName("../../../web/js-file.js")
.hasLineStart(4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class MyPyAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(5);
softly.assertThat(report.get(0))
softly.assertThat(report.get(3))
.hasMessage("\"LogRecord\" has no attribute \"user_uuid\"")
.hasFileName("fs/cs/backend/log.py")
.hasLineStart(16)
.hasSeverity(Severity.WARNING_HIGH);
softly.assertThat(report.get(1))
softly.assertThat(report.get(2))
.hasMessage("\"LogRecord\" has no attribute \"tenant_id\"")
.hasFileName("fs/cs/backend/log.py")
.hasLineStart(17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@ class PitAdapterTest extends AbstractParserTest {
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(2);
softly.assertThat(report.get(0))
.hasMessage(
"NO_COVERAGE, org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator, (Ljava/util/stream/Stream;)V")
.hasFileName("edu/hm/hafner/analysis/Issues.java")
.hasCategory("NO_COVERAGE")
.hasType("org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator")
.hasLineStart(110)
.hasSeverity(Severity.WARNING_NORMAL);
softly.assertThat(report.get(1))
.hasMessage(
"SURVIVED, org.pitest.mutationtest.engine.gregor.mutators.MathMutator, (Ledu/hm/hafner/analysis/Issues;Ledu/hm/hafner/analysis/Issues;)V")
.hasMessage("SURVIVED, org.pitest.mutationtest.engine.gregor.mutators.MathMutator, (Ledu/hm/hafner/analysis/Issues;Ledu/hm/hafner/analysis/Issues;)V")
.hasCategory("SURVIVED")
.hasType("org.pitest.mutationtest.engine.gregor.mutators.MathMutator")
.hasFileName("edu/hm/hafner/analysis/Issues.java")
.hasLineStart(503)
.hasSeverity(Severity.WARNING_HIGH);
softly.assertThat(report.get(1))
.hasMessage("NO_COVERAGE, org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator, (Ljava/util/stream/Stream;)V")
.hasFileName("edu/hm/hafner/analysis/Issues.java")
.hasCategory("NO_COVERAGE")
.hasType("org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator")
.hasLineStart(110)
.hasSeverity(Severity.WARNING_NORMAL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PyDocStyleAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(33);
softly.assertThat(report.get(0))
softly.assertThat(report.get(31))
.hasMessage("Missing docstring in public module")
.hasFileName("fs/csm/admin_api/ui_api.py")
.hasLineStart(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package edu.hm.hafner.analysis.parser.violations;

import java.util.Iterator;

import edu.hm.hafner.analysis.AbstractParserTest;
import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.assertions.SoftAssertions;
Expand All @@ -27,32 +24,30 @@ class ResharperInspectCodeAdapterTest extends AbstractParserTest {
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
assertThat(report).hasSize(3);

Iterator<Issue> iterator = report.iterator();

softly.assertThat(iterator.next())
.hasLineStart(16)
.hasLineEnd(16)
.hasMessage("Cannot resolve symbol 'GetError'. C# Compiler Errors. CSharpErrors")
softly.assertThat(report.get(0))
.hasLineStart(41)
.hasLineEnd(41)
.hasMessage("Convert to auto-property. Language Usage Opportunities. Convert property to auto-property")
.hasFileName("ResharperDemo/Program.cs")
.hasType("CSharpErrors")
.hasSeverity(Severity.WARNING_HIGH);

softly.assertThat(iterator.next())
.hasType("ConvertToAutoProperty")
.hasSeverity(Severity.WARNING_LOW);
softly.assertThat(report.get(1))
.hasLineStart(23)
.hasLineEnd(23)
.hasMessage(
"Expression is always true. Redundancies in Code. Expression is always 'true' or always 'false'")
.hasFileName("ResharperDemo/Program.cs")
.hasType("ConditionIsAlwaysTrueOrFalse")
.hasSeverity(Severity.WARNING_NORMAL);

softly.assertThat(iterator.next())
.hasLineStart(41)
.hasLineEnd(41)
.hasMessage("Convert to auto-property. Language Usage Opportunities. Convert property to auto-property")
softly.assertThat(report.get(2))
.hasLineStart(16)
.hasLineEnd(16)
.hasMessage("Cannot resolve symbol 'GetError'. C# Compiler Errors. CSharpErrors")
.hasFileName("ResharperDemo/Program.cs")
.hasType("ConvertToAutoProperty")
.hasSeverity(Severity.WARNING_LOW);
.hasType("CSharpErrors")
.hasSeverity(Severity.WARNING_HIGH);


}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class XmlLintAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(3);
softly.assertThat(report.get(0))
softly.assertThat(report.get(2))
.hasMessage("Opening and ending tag mismatch: font line 4 and body")
.hasFileName("xml/other.xml")
.hasLineStart(5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class YamlLintAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(4);
softly.assertThat(report.get(0))
softly.assertThat(report.get(2))
.hasMessage("missing starting space in comment")
.hasFileName("file.yml")
.hasLineStart(6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ZptLintAdapterTest extends AbstractParserTest {
@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
softly.assertThat(report).hasSize(2);
softly.assertThat(report.get(0))
softly.assertThat(report.get(1))
.hasMessage("abc def ghe '\" 123")
.hasFileName("cpplint.py")
.hasLineStart(4796)
Expand Down

0 comments on commit 6a76b56

Please sign in to comment.