java - 如何配置 Gradle findbugs 插件以提供更多错误描述?

标签 java gradle findbugs

有没有办法在报告中添加或链接到更多错误描述?

我的意思是在 GUI 模式下对错误的很好解释,例如 RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE

有些错误标题不是很清楚。

描述示例:

RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE : A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.

最佳答案

您可以使用 Violations Gradle Plugin这样做。

它可以积累一堆报告工具,并在构建日志中很好地呈现。

...
se/bjurr/violations/lib/example/OtherClass.java
╔══════════╤════════════╤══════════╤══════╤════════════════════════════════════════════════════╗
║ Reporter │ Rule       │ Severity │ Line │ Message                                            ║
╠══════════╪════════════╪══════════╪══════╪════════════════════════════════════════════════════╣
║ Findbugs │ MS_SHOULD_ │ INFO     │ 7    │ Field isn't final but should be                    ║
║          │ BE_FINAL   │          │      │                                                    ║
║          │            │          │      │                                                    ║
║          │            │          │      │    <p>                                             ║
║          │            │          │      │ This static field public but not final, and        ║
║          │            │          │      │ could be changed by malicious code or              ║
║          │            │          │      │         by accident from another package.          ║
║          │            │          │      │         The field could be made final to avoid     ║
║          │            │          │      │         this vulnerability.</p>                    ║
╟──────────┼────────────┼──────────┼──────┼────────────────────────────────────────────────────╢
║ Findbugs │ NM_FIELD_N │ INFO     │ 6    │ Field names should start with a lower case letter  ║
║          │ AMING_CONV │          │      │                                                    ║
║          │ ENTION     │          │      │                                                    ║
║          │            │          │      │   <p>                                              ║
║          │            │          │      │ Names of fields that are not final should be in mi ║
║          │            │          │      │ xed case with a lowercase first letter and the fir ║
║          │            │          │      │ st letters of subsequent words capitalized.        ║
║          │            │          │      │ </p>                                               ║
╚══════════╧════════════╧══════════╧══════╧════════════════════════════════════════════════════╝

Summary of se/bjurr/violations/lib/example/OtherClass.java
╔══════════╤══════╤══════╤═══════╤═══════╗
║ Reporter │ INFO │ WARN │ ERROR │ Total ║
╠══════════╪══════╪══════╪═══════╪═══════╣
║ Findbugs │ 2    │ 0    │ 0     │ 2     ║
╟──────────┼──────┼──────┼───────┼───────╢
║          │ 2    │ 0    │ 0     │ 2     ║
╚══════════╧══════╧══════╧═══════╧═══════╝


Summary
╔════════════╤══════╤══════╤═══════╤═══════╗
║ Reporter   │ INFO │ WARN │ ERROR │ Total ║
╠════════════╪══════╪══════╪═══════╪═══════╣
║ Checkstyle │ 4    │ 1    │ 1     │ 6     ║
╟────────────┼──────┼──────┼───────┼───────╢
║ Findbugs   │ 2    │ 2    │ 5     │ 9     ║
╟────────────┼──────┼──────┼───────┼───────╢
║            │ 6    │ 3    │ 6     │ 15    ║
╚════════════╧══════╧══════╧═══════╧═══════╝

关于java - 如何配置 Gradle findbugs 插件以提供更多错误描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34084935/

相关文章:

java - 在 Jetty 中部署简单的 Web 应用程序时遇到问题

java - 此方法包含对常量 null 的已知非空值的冗余检查

java - 如何将 findbugs @Nonnull 与外部库一起使用?

java - PMD 和 Findbugs 验证

android - 如何清除gradle缓存?

java - Mockito - 如何忽略私有(private)成员对象的方法调用?

java - 无法存储和加载属性

java - 如何使用 JLabel 在一个程序中添加几张相同的图像?

android - 当我添加 Realm 库时,Telegram Messenger 客户端将无法工作

java - 在 NetBeans 中使用参数运行 Gradle 应用程序