Skip to content

Commit

Permalink
Update to latest Error Prone and Error Prone Gradle plugin (#1064)
Browse files Browse the repository at this point in the history
To stay up to date
  • Loading branch information
msridhar authored Oct 30, 2024
1 parent ef7dc41 commit 238363a
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 83 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
epVersion: 2.31.0
- os: macos-latest
java: 17
epVersion: 2.33.0
epVersion: 2.35.1
- os: windows-latest
java: 17
epVersion: 2.33.0
epVersion: 2.35.1
- os: ubuntu-latest
java: 17
epVersion: 2.33.0
epVersion: 2.35.1
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
run: ./gradlew codeCoverageReport
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.33.0' && github.repository == 'uber/NullAway'
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.35.1' && github.repository == 'uber/NullAway'
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ buildscript {
}
plugins {
id "com.diffplug.spotless" version "6.25.0"
id "net.ltgt.errorprone" version "3.1.0" apply false
id "net.ltgt.errorprone" version "4.1.0" apply false
id "com.github.johnrengelman.shadow" version "8.1.1" apply false
id "me.champeau.jmh" version "0.7.1" apply false
id "com.github.ben-manes.versions" version "0.51.0"
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.util.VersionNumber
// The oldest version of Error Prone that we support running on
def oldestErrorProneVersion = "2.14.0"
// Latest released Error Prone version that we've tested with
def latestErrorProneVersion = "2.33.0"
def latestErrorProneVersion = "2.35.1"
// Default to using latest tested Error Prone version
def defaultErrorProneVersion = latestErrorProneVersion
def errorProneVersionToCompileAgainst = defaultErrorProneVersion
Expand Down
8 changes: 7 additions & 1 deletion nullaway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ plugins {
configurations {
// A configuration holding the jars for the oldest supported version of Error Prone, to use with tests
errorProneOldest

// To resolve the errorprone dependencies for the buildWithNullAway task
errorproneExtended {
extendsFrom errorprone
canBeResolved = true
}
}

dependencies {
Expand Down Expand Up @@ -152,7 +158,7 @@ tasks.register('buildWithNullAway', JavaCompile) {
classpath = sourceSets.main.compileClasspath
destinationDirectory = file("$buildDir/ignoredClasses")
options.annotationProcessorPath = files(
configurations.errorprone.asCollection(),
configurations.errorproneExtended.asCollection(),
sourceSets.main.annotationProcessorPath,
// This refers to the NullAway jar built from the current source
jar.archiveFile.get(),
Expand Down
72 changes: 36 additions & 36 deletions nullaway/src/test/java/com/uber/nullaway/AndroidTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ public void setup() {
public void coreFragmentSuccess() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/core/Fragment.java")
.addSourceFile("android-success/CoreFragment.java")
.addSourceFile("testdata/androidstubs/core/Fragment.java")
.addSourceFile("testdata/android-success/CoreFragment.java")
.doTest();
}

@Test
public void coreFragmentMissingOnAttachError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/core/Fragment.java")
.addSourceFile("android-error/CoreFragmentWithoutOnAttach.java")
.addSourceFile("testdata/androidstubs/core/Fragment.java")
.addSourceFile("testdata/android-error/CoreFragmentWithoutOnAttach.java")
.doTest();
}

@Test
public void coreFragmentMissingOnCreateError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/core/Fragment.java")
.addSourceFile("android-error/CoreFragmentWithoutOnCreate.java")
.addSourceFile("testdata/androidstubs/core/Fragment.java")
.addSourceFile("testdata/android-error/CoreFragmentWithoutOnCreate.java")
.doTest();
}

@Test
public void coreFragmentMissingOnCreateViewError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/core/Fragment.java")
.addSourceFile("android-error/CoreFragmentWithoutOnCreateView.java")
.addSourceFile("testdata/androidstubs/core/Fragment.java")
.addSourceFile("testdata/android-error/CoreFragmentWithoutOnCreateView.java")
.doTest();
}

Expand All @@ -70,35 +70,35 @@ public void coreFragmentMissingOnCreateViewError() {
public void androidxFragmentSuccess() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/androidx/Fragment.java")
.addSourceFile("android-success/AndroidxFragment.java")
.addSourceFile("testdata/androidstubs/androidx/Fragment.java")
.addSourceFile("testdata/android-success/AndroidxFragment.java")
.doTest();
}

@Test
public void androidxFragmentMissingOnAttachError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/androidx/Fragment.java")
.addSourceFile("android-error/AndroidxFragmentWithoutOnAttach.java")
.addSourceFile("testdata/androidstubs/androidx/Fragment.java")
.addSourceFile("testdata/android-error/AndroidxFragmentWithoutOnAttach.java")
.doTest();
}

@Test
public void androidxFragmentMissingOnCreateError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/androidx/Fragment.java")
.addSourceFile("android-error/AndroidxFragmentWithoutOnCreate.java")
.addSourceFile("testdata/androidstubs/androidx/Fragment.java")
.addSourceFile("testdata/android-error/AndroidxFragmentWithoutOnCreate.java")
.doTest();
}

@Test
public void androidxFragmentMissingOnCreateViewError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/androidx/Fragment.java")
.addSourceFile("android-error/AndroidxFragmentWithoutOnCreateView.java")
.addSourceFile("testdata/androidstubs/androidx/Fragment.java")
.addSourceFile("testdata/android-error/AndroidxFragmentWithoutOnCreateView.java")
.doTest();
}

Expand All @@ -108,35 +108,35 @@ public void androidxFragmentMissingOnCreateViewError() {
public void supportLibFragmentSuccess() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/supportlib/Fragment.java")
.addSourceFile("android-success/SupportLibraryFragment.java")
.addSourceFile("testdata/androidstubs/supportlib/Fragment.java")
.addSourceFile("testdata/android-success/SupportLibraryFragment.java")
.doTest();
}

@Test
public void supportLibFragmentMissingOnAttachError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/supportlib/Fragment.java")
.addSourceFile("android-error/SupportLibraryFragmentWithoutOnAttach.java")
.addSourceFile("testdata/androidstubs/supportlib/Fragment.java")
.addSourceFile("testdata/android-error/SupportLibraryFragmentWithoutOnAttach.java")
.doTest();
}

@Test
public void supportLibFragmentMissingOnCreateError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/supportlib/Fragment.java")
.addSourceFile("android-error/SupportLibraryFragmentWithoutOnCreate.java")
.addSourceFile("testdata/androidstubs/supportlib/Fragment.java")
.addSourceFile("testdata/android-error/SupportLibraryFragmentWithoutOnCreate.java")
.doTest();
}

@Test
public void supportLibFragmentMissingOnCreateViewError() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/supportlib/Fragment.java")
.addSourceFile("android-error/SupportLibraryFragmentWithoutOnCreateView.java")
.addSourceFile("testdata/androidstubs/supportlib/Fragment.java")
.addSourceFile("testdata/android-error/SupportLibraryFragmentWithoutOnCreateView.java")
.doTest();
}

Expand All @@ -146,8 +146,8 @@ public void supportLibFragmentMissingOnCreateViewError() {
public void coreActivitySuccess() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/core/Activity.java")
.addSourceFile("android-success/CoreActivity.java")
.addSourceFile("testdata/androidstubs/core/Activity.java")
.addSourceFile("testdata/android-success/CoreActivity.java")
.doTest();
}

Expand All @@ -157,8 +157,8 @@ public void coreActivitySuccess() {
public void supportLibActivitySuccess() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/supportlib/ActivityCompat.java")
.addSourceFile("android-success/SupportLibActivityCompat.java")
.addSourceFile("testdata/androidstubs/supportlib/ActivityCompat.java")
.addSourceFile("testdata/android-success/SupportLibActivityCompat.java")
.doTest();
}

Expand All @@ -168,20 +168,20 @@ public void supportLibActivitySuccess() {
public void androidxActivitySuccess() {
initialiseAndroidCoreClasses();
compilationHelper
.addSourceFile("androidstubs/androidx/ActivityCompat.java")
.addSourceFile("android-success/AndroidxActivityCompat.java")
.addSourceFile("testdata/androidstubs/androidx/ActivityCompat.java")
.addSourceFile("testdata/android-success/AndroidxActivityCompat.java")
.doTest();
}

/** Initialises the default android classes that are commonly used. */
@SuppressWarnings("CheckReturnValue")
private void initialiseAndroidCoreClasses() {
compilationHelper
.addSourceFile("androidstubs/core/Context.java")
.addSourceFile("androidstubs/core/Bundle.java")
.addSourceFile("androidstubs/core/LayoutInflater.java")
.addSourceFile("androidstubs/core/PersistableBundle.java")
.addSourceFile("androidstubs/core/View.java")
.addSourceFile("androidstubs/core/ViewGroup.java");
.addSourceFile("testdata/androidstubs/core/Context.java")
.addSourceFile("testdata/androidstubs/core/Bundle.java")
.addSourceFile("testdata/androidstubs/core/LayoutInflater.java")
.addSourceFile("testdata/androidstubs/core/PersistableBundle.java")
.addSourceFile("testdata/androidstubs/core/View.java")
.addSourceFile("testdata/androidstubs/core/ViewGroup.java");
}
}
4 changes: 2 additions & 2 deletions nullaway/src/test/java/com/uber/nullaway/ContractsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void checkContractPositiveCases() {
temporaryFolder.getRoot().getAbsolutePath(),
"-XepOpt:NullAway:AnnotatedPackages=com.uber",
"-XepOpt:NullAway:CheckContracts=true"))
.addSourceFile("CheckContractPositiveCases.java")
.addSourceFile("testdata/CheckContractPositiveCases.java")
.doTest();
}

Expand All @@ -25,7 +25,7 @@ public void checkContractNegativeCases() {
temporaryFolder.getRoot().getAbsolutePath(),
"-XepOpt:NullAway:AnnotatedPackages=com.uber",
"-XepOpt:NullAway:CheckContracts=true"))
.addSourceFile("CheckContractNegativeCases.java")
.addSourceFile("testdata/CheckContractNegativeCases.java")
.doTest();
}

Expand Down
26 changes: 14 additions & 12 deletions nullaway/src/test/java/com/uber/nullaway/CoreTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,29 @@ public class CoreTests extends NullAwayTestsBase {

@Test
public void coreNullabilityPositiveCases() {
defaultCompilationHelper.addSourceFile("NullAwayPositiveCases.java").doTest();
defaultCompilationHelper.addSourceFile("testdata/NullAwayPositiveCases.java").doTest();
}

@Test
public void nullabilityAnonymousClass() {
defaultCompilationHelper.addSourceFile("NullAwayAnonymousClass.java").doTest();
defaultCompilationHelper.addSourceFile("testdata/NullAwayAnonymousClass.java").doTest();
}

@Test
public void coreNullabilityNegativeCases() {
defaultCompilationHelper
.addSourceFile("NullAwayNegativeCases.java")
.addSourceFile("OtherStuff.java")
.addSourceFile("TestAnnot.java")
.addSourceFile("unannotated/UnannotatedClass.java")
.addSourceFile("testdata/NullAwayNegativeCases.java")
.addSourceFile("testdata/OtherStuff.java")
.addSourceFile("testdata/TestAnnot.java")
.addSourceFile("testdata/unannotated/UnannotatedClass.java")
.doTest();
}

@Test
public void assertSupportPositiveCases() {
defaultCompilationHelper.addSourceFile("CheckAssertSupportPositiveCases.java").doTest();
defaultCompilationHelper
.addSourceFile("testdata/CheckAssertSupportPositiveCases.java")
.doTest();
}

@Test
Expand All @@ -64,7 +66,7 @@ public void assertSupportNegativeCases() {
temporaryFolder.getRoot().getAbsolutePath(),
"-XepOpt:NullAway:AnnotatedPackages=com.uber",
"-XepOpt:NullAway:AssertsEnabled=true"))
.addSourceFile("CheckAssertSupportNegativeCases.java")
.addSourceFile("testdata/CheckAssertSupportNegativeCases.java")
.doTest();
}

Expand Down Expand Up @@ -258,7 +260,7 @@ public void supportSwitchExpression() {
@Test
public void testCastToNonNull() {
defaultCompilationHelper
.addSourceFile("Util.java")
.addSourceFile("testdata/Util.java")
.addSourceLines(
"Test.java",
"package com.uber;",
Expand All @@ -279,7 +281,7 @@ public void testCastToNonNull() {
@Test
public void testCastToNonNullExtraArgsWarning() {
defaultCompilationHelper
.addSourceFile("Util.java")
.addSourceFile("testdata/Util.java")
.addSourceLines(
"Test.java",
"package com.uber;",
Expand Down Expand Up @@ -384,7 +386,7 @@ public void invokeNativeFromInitializer() {

@Test
public void testCapturingScopes() {
defaultCompilationHelper.addSourceFile("CapturingScopes.java").doTest();
defaultCompilationHelper.addSourceFile("testdata/CapturingScopes.java").doTest();
}

@Test
Expand Down Expand Up @@ -635,7 +637,7 @@ public void testMapWithMapGetKey() {

@Test
public void tryFinallySupport() {
defaultCompilationHelper.addSourceFile("NullAwayTryFinallyCases.java").doTest();
defaultCompilationHelper.addSourceFile("testdata/NullAwayTryFinallyCases.java").doTest();
}

@Test
Expand Down
Loading

0 comments on commit 238363a

Please sign in to comment.