aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManu Sridharan <msridhar@gmail.com>2023-10-08 18:05:47 -0700
committerGitHub <noreply@github.com>2023-10-08 21:05:47 -0400
commit2d2b829f47c13ac9cfb1a5b5e339b07b82a240be (patch)
treef00cc4b94ea0b62f947f1af96d75c380e22faf65
parent424cf63d572158d535bd891aa00ab33b640836bc (diff)
downloadnullaway-2d2b829f47c13ac9cfb1a5b5e339b07b82a240be.tar.gz
Update minimum Error Prone version and Guava version (#843)
Fixes #842. Updating the minimum supported Error Prone version to 2.10.0 allows for some code cleanup in tests. We also update our `README.md` (finally!) to mention the new minimum version, to use the Gradle Error Prone plugin correctly, to mention the Gradle NullAway plugin, and to not mention so many specific versions so it doesn't get out of date so quickly in the future. This fixes #466.
-rw-r--r--.github/workflows/continuous-integration.yml4
-rw-r--r--README.md34
-rwxr-xr-xRELEASING.md17
-rwxr-xr-xgradle/dependencies.gradle4
-rw-r--r--guava-recent-unit-tests/build.gradle2
-rw-r--r--nullaway/build.gradle13
-rw-r--r--nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java39
-rw-r--r--nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java21
8 files changed, 27 insertions, 107 deletions
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index 124952f..ec47cd2 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -15,10 +15,10 @@ jobs:
include:
- os: ubuntu-latest
java: 11
- epVersion: 2.4.0
+ epVersion: 2.10.0
- os: ubuntu-latest
java: 17
- epVersion: 2.4.0
+ epVersion: 2.10.0
- os: macos-latest
java: 11
epVersion: 2.22.0
diff --git a/README.md b/README.md
index 41d6e21..1376997 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ NullAway is *fast*. It is built as a plugin to [Error Prone](http://errorprone.
### Overview
-NullAway requires that you build your code with [Error Prone](http://errorprone.info), version 2.4.0 or higher. See the [Error Prone documentation](http://errorprone.info/docs/installation) for instructions on getting started with Error Prone and integration with your build system. The instructions below assume you are using Gradle; see [the docs](https://github.com/uber/NullAway/wiki/Configuration#other-build-systems) for discussion of other build systems.
+NullAway requires that you build your code with [Error Prone](http://errorprone.info), version 2.10.0 or higher. See the [Error Prone documentation](http://errorprone.info/docs/installation) for instructions on getting started with Error Prone and integration with your build system. The instructions below assume you are using Gradle; see [the docs](https://github.com/uber/NullAway/wiki/Configuration#other-build-systems) for discussion of other build systems.
### Gradle
@@ -19,19 +19,18 @@ To integrate NullAway into your non-Android Java project, add the following to y
```gradle
plugins {
// we assume you are already using the Java plugin
- id "net.ltgt.errorprone" version "0.6"
+ id "net.ltgt.errorprone" version "<plugin version>"
}
dependencies {
- annotationProcessor "com.uber.nullaway:nullaway:0.10.13"
+ errorprone "com.uber.nullaway:nullaway:<NullAway version>"
// Optional, some source of nullability annotations.
// Not required on Android if you use the support
// library nullability annotations.
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
- errorprone "com.google.errorprone:error_prone_core:2.4.0"
- errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
+ errorprone "com.google.errorprone:error_prone_core:<Error Prone version>"
}
import net.ltgt.gradle.errorprone.CheckSeverity
@@ -47,23 +46,11 @@ tasks.withType(JavaCompile) {
}
```
-Let's walk through this script step by step. The `plugins` section pulls in the [Gradle Error Prone plugin](https://github.com/tbroyer/gradle-errorprone-plugin) for Error Prone integration. If you are using the older `apply plugin` syntax instead of a `plugins` block, the following is equivalent:
-```gradle
-buildscript {
- repositories {
- gradlePluginPortal()
- }
- dependencies {
- classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
- }
-}
-
-apply plugin: 'net.ltgt.errorprone'
-```
+Let's walk through this script step by step. The `plugins` section pulls in the [Gradle Error Prone plugin](https://github.com/tbroyer/gradle-errorprone-plugin) for Error Prone integration.
-In `dependencies`, the `annotationProcessor` line loads NullAway, and the `compileOnly` line loads a [JSR 305](https://jcp.org/en/jsr/detail?id=305) library which provides a suitable `@Nullable` annotation (`javax.annotation.Nullable`). NullAway allows for any `@Nullable` annotation to be used, so, e.g., `@Nullable` from the Android Support Library or JetBrains annotations is also fine. The `errorprone` line ensures that a compatible version of Error Prone is used, and the `errorproneJavac` line is needed for JDK 8 compatibility.
+In `dependencies`, the first `errorprone` line loads NullAway, and the `compileOnly` line loads a [JSR 305](https://jcp.org/en/jsr/detail?id=305) library which provides a suitable `@Nullable` annotation (`javax.annotation.Nullable`). NullAway allows for any `@Nullable` annotation to be used, so, e.g., `@Nullable` from the Android Support Library or JetBrains annotations is also fine. The second `errorprone` line sets the version of Error Prone is used.
-Finally, in the `tasks.withType(JavaCompile)` section, we pass some configuration options to NullAway. First `check("NullAway", CheckSeverity.ERROR)` sets NullAway issues to the error level (it's equivalent to the `-Xep:NullAway:ERROR` standard Error Prone argument); by default NullAway emits warnings. Then, `option("NullAway:AnnotatedPackages", "com.uber")` (equivalent to the `-XepOpt:NullAway:AnnotatedPackages=com.uber` standard Error Prone argument), tells NullAway that source code in packages under the `com.uber` namespace should be checked for null dereferences and proper usage of `@Nullable` annotations, and that class files in these packages should be assumed to have correct usage of `@Nullable` (see [the docs](https://github.com/uber/NullAway/wiki/Configuration) for more detail). NullAway requires at least the `AnnotatedPackages` configuration argument to run, in order to distinguish between annotated and unannotated code. See [the configuration docs](https://github.com/uber/NullAway/wiki/Configuration) for other useful configuration options.
+Finally, in the `tasks.withType(JavaCompile)` section, we pass some configuration options to NullAway. First `check("NullAway", CheckSeverity.ERROR)` sets NullAway issues to the error level (it's equivalent to the `-Xep:NullAway:ERROR` standard Error Prone argument); by default NullAway emits warnings. Then, `option("NullAway:AnnotatedPackages", "com.uber")` (equivalent to the `-XepOpt:NullAway:AnnotatedPackages=com.uber` standard Error Prone argument) tells NullAway that source code in packages under the `com.uber` namespace should be checked for null dereferences and proper usage of `@Nullable` annotations, and that class files in these packages should be assumed to have correct usage of `@Nullable` (see [the docs](https://github.com/uber/NullAway/wiki/Configuration) for more detail). NullAway requires at least the `AnnotatedPackages` configuration argument to run, in order to distinguish between annotated and unannotated code. See [the configuration docs](https://github.com/uber/NullAway/wiki/Configuration) for other useful configuration options. For even simpler configuration of NullAway options, use the [Gradle NullAway plugin](https://github.com/tbroyer/gradle-nullaway-plugin).
We recommend addressing all the issues that Error Prone reports, particularly those reported as errors (rather than warnings). But, if you'd like to try out NullAway without running other Error Prone checks, you can use `options.errorprone.disableAllChecks` (equivalent to passing `"-XepDisableAllChecks"` to the compiler, before the NullAway-specific arguments).
@@ -75,12 +62,11 @@ The configuration for an Android project is very similar to the Java case, with
```gradle
dependencies {
- annotationProcessor "com.uber.nullaway:nullaway:0.10.13"
- errorprone "com.google.errorprone:error_prone_core:2.4.0"
- errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
+ errorprone "com.uber.nullaway:nullaway:<NullAway version>"
+ errorprone "com.google.errorprone:error_prone_core:<Error Prone version>"
}
```
-A complete Android `build.gradle` example is [here](https://gist.github.com/msridhar/6cacd429567f1d1ad9a278e06809601c). Also see our [sample app](https://github.com/uber/NullAway/blob/master/sample-app/). (The sample app's [`build.gradle`](https://github.com/uber/NullAway/blob/master/sample-app/) is not suitable for direct copy-pasting, as some configuration is inherited from the top-level `build.gradle`.)
+For a more complete example see our [sample app](https://github.com/uber/NullAway/blob/master/sample-app/). (The sample app's [`build.gradle`](https://github.com/uber/NullAway/blob/master/sample-app/) is not suitable for direct copy-pasting, as some configuration is inherited from the top-level `build.gradle`.)
#### Annotation Processors / Generated Code
diff --git a/RELEASING.md b/RELEASING.md
index e9635db..cecfedf 100755
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -29,12 +29,11 @@ Releasing
1. Change the version in `gradle.properties` to a non-SNAPSHOT version.
2. Update the `CHANGELOG.md` for the impending release.
- 3. Update the `README.md` with the new version.
- 4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
- 5. `git tag -a vX.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
- 6. `./gradlew clean publish`
- 7. Update the `gradle.properties` to the next SNAPSHOT version.
- 8. `git commit -am "Prepare next development version."`
- 9. `git push && git push --tags`
- 10. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact.
- 11. Go to [this page](https://github.com/uber/NullAway/releases/new) to create a new release on GitHub, using the release notes from `CHANGELOG.md`.
+ 3. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
+ 4. `git tag -a vX.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
+ 5. `./gradlew clean publish`
+ 6. Update the `gradle.properties` to the next SNAPSHOT version.
+ 7. `git commit -am "Prepare next development version."`
+ 8. `git push && git push --tags`
+ 9. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact.
+ 10. Go to [this page](https://github.com/uber/NullAway/releases/new) to create a new release on GitHub, using the release notes from `CHANGELOG.md`.
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index e31eb38..0e295a9 100755
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -17,7 +17,7 @@ import org.gradle.util.VersionNumber
*/
// The oldest version of Error Prone that we support running on
-def oldestErrorProneVersion = "2.4.0"
+def oldestErrorProneVersion = "2.10.0"
// Latest released Error Prone version that we've tested with
def latestErrorProneVersion = "2.22.0"
// Default to using latest tested Error Prone version
@@ -72,7 +72,7 @@ def build = [
errorProneJavac : "com.google.errorprone:javac:9+181-r4173-1",
errorProneTestHelpers : "com.google.errorprone:error_prone_test_helpers:${versions.errorProneApi}",
checkerDataflow : "org.checkerframework:dataflow-nullaway:${versions.checkerFramework}",
- guava : "com.google.guava:guava:24.1.1-jre",
+ guava : "com.google.guava:guava:30.1-jre",
javaxValidation : "javax.validation:validation-api:2.0.1.Final",
jspecify : "org.jspecify:jspecify:0.3.0",
jsr305Annotations : "com.google.code.findbugs:jsr305:3.0.2",
diff --git a/guava-recent-unit-tests/build.gradle b/guava-recent-unit-tests/build.gradle
index 4d78ac5..7740123 100644
--- a/guava-recent-unit-tests/build.gradle
+++ b/guava-recent-unit-tests/build.gradle
@@ -35,7 +35,7 @@ dependencies {
def jdk8Test = tasks.register("testJdk8", Test) {
onlyIf {
// Only if we are using a version of Error Prone compatible with JDK 8
- deps.versions.errorProneApi == "2.4.0"
+ deps.versions.errorProneApi == "2.10.0"
}
javaLauncher = javaToolchains.launcherFor {
diff --git a/nullaway/build.gradle b/nullaway/build.gradle
index 83f7e62..8000dbc 100644
--- a/nullaway/build.gradle
+++ b/nullaway/build.gradle
@@ -70,17 +70,6 @@ javadoc {
failOnError = false
}
-
-test {
- if (deps.versions.errorProneApi == "2.4.0" && JavaVersion.current() >= JavaVersion.VERSION_17) {
- // This test does not pass on JDK 17 with Error Prone 2.4.0 due to a Mockito incompatibility. Skip it (the
- // test passes with more recent Error Prone versions on JDK 17)
- filter {
- excludeTestsMatching "com.uber.nullaway.NullAwaySerializationTest.suggestNullableArgumentOnBytecodeNoFileInfo"
- }
- }
-}
-
apply plugin: 'com.vanniktech.maven.publish'
// These --add-exports arguments are required when targeting JDK 11+ since Error Prone and NullAway access a bunch of
@@ -107,7 +96,7 @@ apply plugin: 'com.vanniktech.maven.publish'
def jdk8Test = tasks.register("testJdk8", Test) {
onlyIf {
// Only if we are using a version of Error Prone compatible with JDK 8
- deps.versions.errorProneApi == "2.4.0"
+ deps.versions.errorProneApi == "2.10.0"
}
javaLauncher = javaToolchains.launcherFor {
diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java
index 4ed8792..1817d25 100644
--- a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java
+++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestNoCastTest.java
@@ -23,8 +23,6 @@
package com.uber.nullaway;
import com.google.errorprone.BugCheckerRefactoringTestHelper;
-import com.google.errorprone.ErrorProneFlags;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -36,54 +34,21 @@ public class NullAwayAutoSuggestNoCastTest {
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
- private ErrorProneFlags flagsWithAutoFixSuppressionComment;
-
- private ErrorProneFlags flagsNoAutoFixSuppressionComment;
-
- @Before
- public void setup() {
- // With AutoFixSuppressionComment
- ErrorProneFlags.Builder b = ErrorProneFlags.builder();
- b.putFlag("NullAway:AnnotatedPackages", "com.uber,com.ubercab,io.reactivex");
- b.putFlag("NullAway:SuggestSuppressions", "true");
- b.putFlag("NullAway:AutoFixSuppressionComment", "PR #000000");
- flagsWithAutoFixSuppressionComment = b.build();
- // Without AutoFixSuppressionComment
- b = ErrorProneFlags.builder();
- b.putFlag("NullAway:AnnotatedPackages", "com.uber,com.ubercab,io.reactivex");
- b.putFlag("NullAway:SuggestSuppressions", "true");
- flagsNoAutoFixSuppressionComment = b.build();
- }
-
- // In EP 2.6.0 the newInstance() method we use below is deprecated. We cannot currently address
- // the warning since the replacement method was only added in EP 2.5.1, and we still want to
- // support EP 2.4.0. So, we suppress the warning for now
- @SuppressWarnings("deprecation")
private BugCheckerRefactoringTestHelper makeTestHelperWithSuppressionComment() {
- return BugCheckerRefactoringTestHelper.newInstance(
- new NullAway(flagsWithAutoFixSuppressionComment), getClass())
+ return BugCheckerRefactoringTestHelper.newInstance(NullAway.class, getClass())
.setArgs(
"-d",
temporaryFolder.getRoot().getAbsolutePath(),
- // the remaining args are not needed right now, but they will be necessary when we
- // switch to the more modern newInstance() API
"-XepOpt:NullAway:AnnotatedPackages=com.uber,com.ubercab,io.reactivex",
"-XepOpt:NullAway:SuggestSuppressions=true",
"-XepOpt:NullAway:AutoFixSuppressionComment=PR #000000");
}
- // In EP 2.6.0 the newInstance() method we use below is deprecated. We cannot currently address
- // the warning since the replacement method was only added in EP 2.5.1, and we still want to
- // support EP 2.4.0. So, we suppress the warning for now
- @SuppressWarnings("deprecation")
private BugCheckerRefactoringTestHelper makeTestHelper() {
- return BugCheckerRefactoringTestHelper.newInstance(
- new NullAway(flagsNoAutoFixSuppressionComment), getClass())
+ return BugCheckerRefactoringTestHelper.newInstance(NullAway.class, getClass())
.setArgs(
"-d",
temporaryFolder.getRoot().getAbsolutePath(),
- // the remaining args are not needed right now, but they will be necessary when we
- // switch to the more modern newInstance() API
"-XepOpt:NullAway:AnnotatedPackages=com.uber,com.ubercab,io.reactivex",
"-XepOpt:NullAway:SuggestSuppressions=true");
}
diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java
index 03ae7e3..ba5eabe 100644
--- a/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java
+++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayAutoSuggestTest.java
@@ -25,11 +25,9 @@ package com.uber.nullaway;
import static com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH;
import com.google.errorprone.BugCheckerRefactoringTestHelper;
-import com.google.errorprone.ErrorProneFlags;
import com.sun.source.tree.Tree;
import com.uber.nullaway.testlibrarymodels.TestLibraryModels;
import java.io.IOException;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -41,30 +39,13 @@ public class NullAwayAutoSuggestTest {
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
- private ErrorProneFlags flags;
-
- @Before
- public void setup() {
- ErrorProneFlags.Builder b = ErrorProneFlags.builder();
- b.putFlag("NullAway:AnnotatedPackages", "com.uber,com.ubercab,io.reactivex");
- b.putFlag("NullAway:CastToNonNullMethod", "com.uber.nullaway.testdata.Util.castToNonNull");
- b.putFlag("NullAway:SuggestSuppressions", "true");
- flags = b.build();
- }
-
- // In EP 2.6.0 the newInstance() method we use below is deprecated. We cannot currently address
- // the warning since the replacement method was only added in EP 2.5.1, and we still want to
- // support EP 2.4.0. So, we suppress the warning for now
- @SuppressWarnings("deprecation")
private BugCheckerRefactoringTestHelper makeTestHelper() {
- return BugCheckerRefactoringTestHelper.newInstance(new NullAway(flags), getClass())
+ return BugCheckerRefactoringTestHelper.newInstance(NullAway.class, getClass())
.setArgs(
"-d",
temporaryFolder.getRoot().getAbsolutePath(),
"-processorpath",
TestLibraryModels.class.getProtectionDomain().getCodeSource().getLocation().getPath(),
- // the remaining args are not needed right now, but they will be necessary when we
- // switch to the more modern newInstance() API
"-XepOpt:NullAway:AnnotatedPackages=com.uber,com.ubercab,io.reactivex",
"-XepOpt:NullAway:CastToNonNullMethod=com.uber.nullaway.testdata.Util.castToNonNull",
"-XepOpt:NullAway:SuggestSuppressions=true");