Skip to content

Commit d40de5e

Browse files
authored
Update to Error Prone 2.38.0 (#1203)
1 parent 4987a2e commit d40de5e

5 files changed

Lines changed: 19 additions & 13 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ jobs:
2525
epVersion: 2.31.0
2626
- os: macos-latest
2727
java: 17
28-
epVersion: 2.37.0
28+
epVersion: 2.38.0
2929
- os: windows-latest
3030
java: 17
31-
epVersion: 2.37.0
31+
epVersion: 2.38.0
3232
- os: ubuntu-latest
3333
java: 17
34-
epVersion: 2.37.0
34+
epVersion: 2.38.0
3535
fail-fast: false
3636
runs-on: ${{ matrix.os }}
3737
steps:
@@ -60,7 +60,7 @@ jobs:
6060
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
6161
run: ./gradlew codeCoverageReport
6262
continue-on-error: true
63-
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.37.0' && github.repository == 'uber/NullAway'
63+
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.38.0' && github.repository == 'uber/NullAway'
6464
- name: Upload coverage reports to Codecov
6565
uses: codecov/codecov-action@v4
6666
with:

gradle/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.gradle.util.VersionNumber
1919
// The oldest version of Error Prone that we support running on
2020
def oldestErrorProneVersion = "2.14.0"
2121
// Latest released Error Prone version that we've tested with
22-
def latestErrorProneVersion = "2.37.0"
22+
def latestErrorProneVersion = "2.38.0"
2323
// Default to using latest tested Error Prone version
2424
def defaultErrorProneVersion = latestErrorProneVersion
2525
def errorProneVersionToCompileAgainst = defaultErrorProneVersion

nullaway/src/main/java/com/uber/nullaway/CodeAnnotationInfo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ public boolean isGenerated(Symbol symbol, Config config) {
118118
// One known case where this can happen: int.class, void.class, etc.
119119
Preconditions.checkArgument(
120120
isClassFieldOfPrimitiveType(symbol),
121-
String.format(
122-
"Unexpected symbol passed to CodeAnnotationInfo.isGenerated(...) with null enclosing class: %s",
123-
symbol));
121+
"Unexpected symbol passed to CodeAnnotationInfo.isGenerated(...) with null enclosing class: %s",
122+
symbol);
124123
return false;
125124
}
126125
Symbol.ClassSymbol outermostClassSymbol = get(classSymbol, config, null).outermostClassSymbol;

nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,14 @@ private Description.Builder removeCastToNonNullFix(
379379
Tree currTree = state.getPath().getLeaf();
380380
Preconditions.checkArgument(
381381
currTree.getKind() == Tree.Kind.METHOD_INVOCATION,
382-
String.format("Expected castToNonNull invocation expression, found:\n%s", currTree));
382+
"Expected castToNonNull invocation expression, found:\n%s",
383+
currTree);
383384
MethodInvocationTree invTree = (MethodInvocationTree) currTree;
384385
Preconditions.checkArgument(
385386
invTree.getArguments().contains(suggestTree),
386-
String.format(
387-
"Method invocation tree %s does not contain the expression %s as an argument being cast",
388-
invTree, suggestTree));
387+
"Method invocation tree %s does not contain the expression %s as an argument being cast",
388+
invTree,
389+
suggestTree);
389390
// Remove the call to castToNonNull:
390391
SuggestedFix fix =
391392
SuggestedFix.builder().replace(invTree, state.getSourceForNode(suggestTree)).build();

nullaway/src/main/java/com/uber/nullaway/LibraryModels.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,13 @@ public static MethodRef fromSymbol(Symbol.MethodSymbol symbol) {
256256
* produced by {@link Symbol.MethodSymbol#toString()} and will not work for arbitrary strings.
257257
*/
258258
private static String stripAnnotationsFromMethodSymbolString(String str) {
259-
return str.replaceAll("@[^ ]+ ", "");
259+
String annotationWithSpace = "@[\\w.]+\\s";
260+
// annotations within a varargs array can look like:
261+
262+
// we want to match the annotation without consuming the ellipsis, so we use a lookahead
263+
String annotationOfVarargsArray = "@[\\w.]+(?=\\.\\.\\.)";
264+
String annotationRegex = annotationWithSpace + "|" + annotationOfVarargsArray;
265+
return str.replaceAll(annotationRegex, "");
260266
}
261267

262268
@Override

0 commit comments

Comments
 (0)