Skip to content

Commit

Permalink
Upgrade Error Prone 2.19.1 -> 2.20.0 (#685)
Browse files Browse the repository at this point in the history
Summary of key changes:
- The `MissingRefasterAnnotation` check was contributed to Error Prone,
  and so is deleted here (multiple checks with the same name are not
  supported).
- Similarly, Error Prone now supports the `-XepAllSuggestionsAsWarnings`
  flag out of the box. So the `ErrorProneFork` class is deleted, as it
  has currently no further use.

While there, include a tweak to `run-mutation-tests.sh`.

Fixes #686.

See:
- https://github.com/google/error-prone/releases/tag/v2.20.0
- google/error-prone@v2.19.1...v2.20.0
- PicnicSupermarket/error-prone@v2.19.1-picnic-1...v2.20.0-picnic-1
  • Loading branch information
Stephan202 committed Jun 20, 2023
1 parent 8fb57b5 commit b81ec97
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 348 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void after(Set<T> removeFrom, Collection<S> elementsToRemove) {
}

/** Prefer {@link ArrayList#ArrayList(Collection)} over the Guava alternative. */
@SuppressWarnings(
"NonApiType" /* Matching against `List` would unnecessarily constrain the rule. */)
static final class NewArrayListFromCollection<T> {
@BeforeTemplate
ArrayList<T> before(Collection<T> collection) {
Expand Down

This file was deleted.

7 changes: 5 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<version.auto-value>1.10.1</version.auto-value>
<version.error-prone>${version.error-prone-orig}</version.error-prone>
<version.error-prone-fork>v${version.error-prone-orig}-picnic-1</version.error-prone-fork>
<version.error-prone-orig>2.19.1</version.error-prone-orig>
<version.error-prone-orig>2.20.0</version.error-prone-orig>
<version.error-prone-slf4j>0.1.18</version.error-prone-slf4j>
<version.guava-beta-checker>1.0</version.guava-beta-checker>
<version.jdk>11</version.jdk>
Expand Down Expand Up @@ -972,7 +972,7 @@
<banDuplicateClasses>
<dependencies>
<dependency>
<groupId>org.checkerframework</groupId>
<groupId>io.github.eisop</groupId>
<artifactId>dataflow-errorprone</artifactId>
<!-- This package is contained in
Checker Framework's `checker-qual` and
Expand Down Expand Up @@ -1720,6 +1720,9 @@
-Xep:Java7ApiChecker:OFF
<!-- We don't target JDK 8. -->
-Xep:Java8ApiChecker:OFF
<!-- XXX: Triggers an IOOBE. See
https://github.com/google/error-prone/pull/3976. -->
-Xep:MemberName:OFF
<!-- We don't target Android. -->
-Xep:StaticOrDefaultInterfaceMethod:OFF
<!-- We generally discourage `var` use. -->
Expand Down
1 change: 1 addition & 0 deletions refaster-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>refaster-support</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import tech.picnic.errorprone.refaster.ErrorProneFork;

final class RefasterTest {
private final CompilationTestHelper compilationHelper =
Expand Down Expand Up @@ -80,74 +79,66 @@ private static Stream<Arguments> severityAssignmentTestCases() {
SeverityLevel defaultSeverity = BugCheckerInfo.create(Refaster.class).defaultSeverity();

/* { arguments, expectedSeverities } */
return Stream.concat(
Stream.of(
arguments(
ImmutableList.of(), ImmutableList.of(defaultSeverity, WARNING, ERROR, SUGGESTION)),
arguments(ImmutableList.of("-Xep:Refaster:OFF"), ImmutableList.of()),
arguments(
ImmutableList.of("-Xep:Refaster:DEFAULT"),
ImmutableList.of(defaultSeverity, WARNING, ERROR, SUGGESTION)),
arguments(
ImmutableList.of("-Xep:Refaster:WARN"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:ERROR"),
ImmutableList.of(ERROR, ERROR, ERROR, ERROR)),
arguments(
ImmutableList.of("-XepAllErrorsAsWarnings"),
ImmutableList.of(defaultSeverity, WARNING, WARNING, SUGGESTION)),
arguments(
ImmutableList.of("-Xep:Refaster:OFF", "-XepAllErrorsAsWarnings"),
ImmutableList.of()),
arguments(
ImmutableList.of("-Xep:Refaster:DEFAULT", "-XepAllErrorsAsWarnings"),
ImmutableList.of(defaultSeverity, WARNING, WARNING, SUGGESTION)),
arguments(
ImmutableList.of("-Xep:Refaster:WARN", "-XepAllErrorsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:ERROR", "-XepAllErrorsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING))),
ErrorProneFork.isErrorProneForkAvailable()
? Stream.of(
arguments(
ImmutableList.of("-Xep:Refaster:OFF", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of()),
arguments(
ImmutableList.of("-Xep:Refaster:DEFAULT", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, ERROR, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:WARN", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:ERROR", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(ERROR, ERROR, ERROR, ERROR)),
arguments(
ImmutableList.of(
"-Xep:Refaster:OFF",
"-XepAllErrorsAsWarnings",
"-XepAllSuggestionsAsWarnings"),
ImmutableList.of()),
arguments(
ImmutableList.of(
"-Xep:Refaster:DEFAULT",
"-XepAllErrorsAsWarnings",
"-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of(
"-Xep:Refaster:WARN",
"-XepAllErrorsAsWarnings",
"-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of(
"-Xep:Refaster:ERROR",
"-XepAllErrorsAsWarnings",
"-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)))
: Stream.empty());
return Stream.of(
arguments(
ImmutableList.of(), ImmutableList.of(defaultSeverity, WARNING, ERROR, SUGGESTION)),
arguments(ImmutableList.of("-Xep:Refaster:OFF"), ImmutableList.of()),
arguments(
ImmutableList.of("-Xep:Refaster:DEFAULT"),
ImmutableList.of(defaultSeverity, WARNING, ERROR, SUGGESTION)),
arguments(
ImmutableList.of("-Xep:Refaster:WARN"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:ERROR"), ImmutableList.of(ERROR, ERROR, ERROR, ERROR)),
arguments(
ImmutableList.of("-XepAllErrorsAsWarnings"),
ImmutableList.of(defaultSeverity, WARNING, WARNING, SUGGESTION)),
arguments(
ImmutableList.of("-Xep:Refaster:OFF", "-XepAllErrorsAsWarnings"), ImmutableList.of()),
arguments(
ImmutableList.of("-Xep:Refaster:DEFAULT", "-XepAllErrorsAsWarnings"),
ImmutableList.of(defaultSeverity, WARNING, WARNING, SUGGESTION)),
arguments(
ImmutableList.of("-Xep:Refaster:WARN", "-XepAllErrorsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:ERROR", "-XepAllErrorsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, ERROR, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:OFF", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of()),
arguments(
ImmutableList.of("-Xep:Refaster:DEFAULT", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, ERROR, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:WARN", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of("-Xep:Refaster:ERROR", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(ERROR, ERROR, ERROR, ERROR)),
arguments(
ImmutableList.of("-XepAllErrorsAsWarnings", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of(
"-Xep:Refaster:OFF", "-XepAllErrorsAsWarnings", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of()),
arguments(
ImmutableList.of(
"-Xep:Refaster:DEFAULT", "-XepAllErrorsAsWarnings", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of(
"-Xep:Refaster:WARN", "-XepAllErrorsAsWarnings", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)),
arguments(
ImmutableList.of(
"-Xep:Refaster:ERROR", "-XepAllErrorsAsWarnings", "-XepAllSuggestionsAsWarnings"),
ImmutableList.of(WARNING, WARNING, WARNING, WARNING)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ private static <A extends Annotation> Optional<A> getAnnotationValue(

private static SeverityLevel overrideSeverity(SeverityLevel severity, Context context) {
ErrorProneOptions options = context.get(ErrorProneOptions.class);
SeverityLevel minSeverity =
ErrorProneFork.isSuggestionsAsWarningsEnabled(options) ? WARNING : SUGGESTION;
SeverityLevel minSeverity = options.isSuggestionsAsWarnings() ? WARNING : SUGGESTION;
SeverityLevel maxSeverity = options.isDropErrorsToWarnings() ? WARNING : ERROR;

return Comparators.max(Comparators.min(severity, minSeverity), maxSeverity);
Expand Down
Loading

0 comments on commit b81ec97

Please sign in to comment.