Catch common Java mistakes as compile-time errors
Catch common Java mistakes as compile-time errors
Error Prone is a static analysis tool for Java that catches common programming mistakes at compile-time.
public class ShortSet {
public static void main (String[] args) {
Set<Short> s = new HashSet<>();
for (short i = 0; i < 100; i++) {
s.add(i);
s.remove(i - 1);
}
System.out.println(s.size());
}
}error: [CollectionIncompatibleType] Argument 'i - 1' should not be passed to this method;
its type int is not compatible with its collection's type argument Short
s.remove(i - 1);
^
(see https://errorprone.info/bugpattern/CollectionIncompatibleType)
1 errorOur documentation is at errorprone.info.
Error Prone works with Bazel, Maven, Ant, and Gradle. See our installation instructions for details.
Developing and building Error Prone is documented on the wiki.
MisformattedTestData suggested fix wraps long `// BUG: Diagnostic contains: ` lines
Check MessageFormat patterns and arguments, including in methods that delegate to MessageFormat
CompilationTestHelper reports only the first line that fails its expectation
New check request: OutputStream subclasses that inherit the per-byte write(byte[], int, int)
Unknown error that error prone told me to report
NonApiType: signaling for use of non-API-types on private methods does not make sense
Per-check timing spans cost a few percent of the compile, and nothing reads the timings
Maven multi-line <arg> does not work on Windows when <fork>ed
[feat.request] add comparative in README.md to error-prone alternatives
ThreadSafe is not a valid checker name