将常见的 Java 错误在编译期捕获
Error Prone 是一个 Java 静态分析工具,可在编译时捕获常见的编程错误。
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 error我们的文档位于 errorprone.info。
Error Prone 可与 Bazel 配合使用,详情请见相关说明。
有关开发和构建 Error Prone 的说明,请参阅以下文档
Maven, Ant, and Gradle. See our installation instructions for wiki.
MisformattedTestData 建议的修复包含了长的 `// BUG: Diagnostic 含有: ` 行
检查 MessageFormat 模式和参数,包括委托给 MessageFormat 的方法
CompilationTestHelper 只报告第一行失败其预期的情况
新的检查请求:继承 per-byte write(byte[], int, int) 的 OutputStream 子类
未知错误,易出错的提示我要报告此错误
NonApiType: 在私有方法上使用非 API 类型的信令没有意义
每次检查的计时耗费了编译时间的几个百分点,而且没有任何程序读取这些计时信息。
在 <fork> 后,在 Windows 上的 Maven 多行 <arg> 不能正常工作
[feat.request] 在 README.md 中添加对比信息,以便对易出错的替代方案进行说明
ThreadSafe 不是有效的检查器名称