【问题标题】:How to configure Gradle findbugs plugin to provide more description for bugs?如何配置 Gradle findbugs 插件以提供更多错误描述?
【发布时间】:2016-03-09 04:26:16
【问题描述】:

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

我的意思是对 GUI 模式中的 RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE 之类的错误进行很好的解释。

一些错误标题并没有立即清楚。

描述示例:

RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE : 检查一个值 这里看看是否为null,但是这个值不能为null,因为 它以前被取消引用,如果它为空,则为空指针 在较早的取消引用时会发生异常。本质上, 此代码和先前的取消引用不同意这是否 值允许为空。要么检查是多余的,要么 之前的取消引用是错误的。

【问题讨论】:

    标签: java gradle findbugs


    【解决方案1】:

    您可以使用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    ║
    ╚════════════╧══════╧══════╧═══════╧═══════╝
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-30
      相关资源
      最近更新 更多