google / google/error-prone

lombok causes an IndexOutOfBoundsException in UnusedVariable

Open
#1,250 19 comments 10 reactions 0 assignees View on GitHub
lombok
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

### Description of the problem / feature request:

`./gradlew clean compileJava` throws this error

```
Service.java:1: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
package io.mine.service.grpc;
^
Please report this at https://github.com/google/error-prone/issues/new and include the following:

error-prone version: 2.3.3
BugPattern: UnusedVariable
Stack Trace:
java.lang.IndexOutOfBoundsException
at java.nio.HeapCharBuffer.subSequence(HeapCharBuffer.java:580)
at java.nio.HeapCharBuffer.subSequence(HeapCharBuffer.java:42)
at com.google.errorprone.fixes.SuggestedFixes.replaceIncludingComments(SuggestedFixes.java:1021)
at com.google.errorprone.bugpatterns.UnusedVariable.buildUnusedVarFixes(UnusedVariable.java:387)
at com.google.errorprone.bugpatterns.UnusedVariable.matchCompilationUnit(UnusedVariable.java:239)
at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:433)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:541)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:150)
```

### Feature requests: what underlying problem are you trying to solve with this feature?

none, its applied by error-prone `2.3.3`

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

### What version of Error Prone are you using?
`errorproneJavacVersion = "9+181-r4173-1"`
`errorproneVersion = "2.3.2"`
`errorpronePluginVersion = "0.7.1"`

`openjdk version "1.8.0_192"`

### Have you found anything relevant by searching the web?

reverting back to `2.3.2` fixes the problem.
I tried to exclude the BugPattern but that does not work:

```
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.annotationProcessorPath = configurations.errorprone
options.errorprone.enabled = true
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.excludedPaths = ".*/build/gen.*/.*"
options.errorprone.errorproneArgs = ["-Xep:ParameterName:OFF",
"Xep:UnusedVariable:OFF"]
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.