Skip to content

2.19.x: Exception thrown when a disabled check is passed to -XepPatchChecks #3908

Closed
@AlexLandau

Description

Standalone repro: https://github.com/AlexLandau/errorprone-disabled-and-patch-issue

We have some odd situations involving automated tooling where sometimes, we will run patch creation on checks that have also been disabled; that is, we end up with both -Xep:CheckName:OFF and -XepPatchChecks:CheckName. In 2.18.0, this resulted in the patch being created as if it weren't disabled. Starting in 2.19.0 (and through the current version, 2.19.1), an exception is thrown instead:

/home/alandau/code/gradle-disabled-and-patch-issue/lib/src/main/java/com/github/alexlandau/repro/Library.java:5: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
    public String toString() {
                  ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:

     error-prone version: 2.19.1
     BugPattern: MissingOverride
     Stack Trace:
     java.util.NoSuchElementException: No value present
        at java.base/java.util.Optional.get(Optional.java:143)
        at com.google.errorprone.matchers.Description.severity(Description.java:78)
        at com.google.errorprone.ErrorProneAnalyzer.lambda$finished$1(ErrorProneAnalyzer.java:138)
        at com.google.errorprone.VisitorState.reportMatch(VisitorState.java:301)
        at com.google.errorprone.scanner.Scanner.reportMatch(Scanner.java:127)
        at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:448)
        at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:739)
        (etc., full stacktrace in repo linked above)

We can work around this for the time being (editing the -Xep args to make sure the check isn't disabled).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions