diff --git a/README.md b/README.md index 02acb509..ab476bb3 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ It supports: * [_GoLint_](https://github.com/golang/lint) * [_GoVet_](https://golang.org/cmd/vet/) Same format as GoLint. * [_GoogleErrorProne_](https://github.com/google/error-prone) + * [_NullAway_](https://github.com/uber/NullAway) * [_JSHint_](http://jshint.com/) * _Lint_ A common XML format, used by different linters. * [_JCReport_](https://github.com/jCoderZ/fawkez/wiki/JcReport) diff --git a/src/test/java/se/bjurr/violations/lib/GoogleErrorProneTest.java b/src/test/java/se/bjurr/violations/lib/GoogleErrorProneTest.java index 4dbeffe5..a2e7f34b 100644 --- a/src/test/java/se/bjurr/violations/lib/GoogleErrorProneTest.java +++ b/src/test/java/se/bjurr/violations/lib/GoogleErrorProneTest.java @@ -8,7 +8,9 @@ import static se.bjurr.violations.lib.reports.Parser.GOOGLEERRORPRONE; import java.util.List; + import org.junit.Test; + import se.bjurr.violations.lib.model.Violation; public class GoogleErrorProneTest { @@ -80,4 +82,31 @@ public void testThatViolationsCanBeParsedMaven() { assertThat(violation0.getStartLine()) // .isEqualTo(20); } + + @Test + public void testThatViolationsCanBeParsedGradleNullAway() { + final String rootFolder = getRootFolder(); + + final List actual = + violationsApi() // + .withPattern(".*/googleErrorProne/nullAway\\.log$") // + .inFolder(rootFolder) // + .findAll(GOOGLEERRORPRONE) // + .violations(); + + assertThat(actual) // + .hasSize(2); + + final Violation violation0 = actual.get(0); + assertThat(violation0.getMessage()) // + .endsWith("nullaway )"); + assertThat(violation0.getFile()) // + .isEqualTo("home/travis/build/leinardi/FloatingActionButtonSpeedDial/library/src/main/java/com/leinardi/android/speeddial/SpeedDialActionItem.java"); + assertThat(violation0.getSeverity()) // + .isEqualTo(ERROR); + assertThat(violation0.getRule().get()) // + .isEqualTo("NullAway"); + assertThat(violation0.getStartLine()) // + .isEqualTo(162); + } } diff --git a/src/test/resources/googleErrorProne/nullAway.log b/src/test/resources/googleErrorProne/nullAway.log new file mode 100644 index 00000000..f283c659 --- /dev/null +++ b/src/test/resources/googleErrorProne/nullAway.log @@ -0,0 +1,11 @@ +:sample:compileReleaseNdk NO-SOURCE +:sample:processReleaseJavaRes NO-SOURCE +/home/travis/build/leinardi/FloatingActionButtonSpeedDial/library/src/main/java/com/leinardi/android/speeddial/SpeedDialActionItem.java:162: error: [NullAway] initializer method does not guarantee @NonNull field mLabel is initialized along all control-flow paths (remember to check for exceptions or early returns). + public Builder(@IdRes int id, @DrawableRes int fabImageResource) { + ^ + (see http://t.uber.com/nullaway ) +/home/travis/build/leinardi/FloatingActionButtonSpeedDial/library/src/main/java/com/leinardi/android/speeddial/SpeedDialActionItem.java:175: error: [NullAway] initializer method does not guarantee @NonNull field mLabel is initialized along all control-flow paths (remember to check for exceptions or early returns). + public Builder(@IdRes int id, @Nullable Drawable drawable) { + ^ + (see http://t.uber.com/nullaway ) +2 errors