如何配置Gradle findbugs插件来提供bug的更多描述? [英] How to configure Gradle findbugs plugin to provide more description for bugs?

查看:538
本文介绍了如何配置Gradle findbugs插件来提供bug的更多描述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的意思是很好的解释错误,比如 RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE

有没有方法在报告中添加或链接到更多错误描述? code>就像在GUI模式中一样。



一些错误标题不会立即清除。对于一个描述:


RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE :在这里检查
以查看它是否为空,但是该值不能为空,因为之前解除引用
,并且如果它为空,则在先前的解除引用时会出现空指针
异常。实质上,
这段代码和之前的解引用不同意这个
值是否允许为空。检查是多余的,或
之前的解除引用是错误的。



解决方案

您可以使用 Violations Gradle Plugin 来做到这一点。


$

  ... b $ b 

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


se / bjurr / violations / lib / example / OtherClass.java
╔═══════════════════════════════════════ ══════╤══════╤════════════════════════════════════ ═══════════
║记者│规则│严重程度│行│留言║
╠════════════════ ══════════╪══════════╪ ══════╪═══════════════════════════════════════════ ════════╣$ b $ FindBugs│MS_SHOULD_│INFO│7│字段不是最终的,但应该是b
║│BE_FINAL│││║
║││ ││║
║││││< p> ║
║││││这个静态字段公开但不是最终的,并且║
║││││可能会被恶意代码或║
║││││改变包。 ║
║││││该字段可以作出最终避免║
║││││此漏洞。< / p> ║
╟──────────────────────────────────────────────────────── ────────────────────────────────────────────────── ╢
║Findbugs│NM_FIELD_N│INFO│6│字段名称应以小写字母开头║
║│AMING_CONV│││║
║│ENTION│││║
║││││< p> ║
║││││不是最终字段的域名应该是mi║
║│││x x with with with with lower first letter letter letter║║║║
║│││ │后续单词的大写字母大写。 ║
║││││< / p> ║
╚═════════════════════════════════════════════════ ══════════════════════════════════════════════════ ╝

se / bjurr /违规/ lib / example / OtherClass.java
╔════════════════════════════════ ══════════════
║记者│信息│警告│错误│总计║
╠═══════════ ╪════════════════════════
FindBugs│2│0│0│2║
╟───────────────────────────────────────────────────────────────$
║│2│ 0│0│2║
╚══════════════════════════════════════ ═╧═══════════════════════════


总结
╔═════════ ═══════════════════════════════$ b $║记者│信息│警告│错误│总计║
╠════════════════╣$╠═══════╪╪╪═══╪╣╣╣╣╣╣╣
║Checkstyle│4│1│1│6║
╟────────────┼─────────────────── ───────────╢
║Findbugs│2│2│5│9║
╟─────────────────── ─┼───────┼───────┼───────╢
║│6│3│6│15║
╚═══════ ══════╧══════╧══════╧═══ ═══╧═══════╝


Is there a way to add or link to more bug descriptions in the report?

I mean good explanations of errors like RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE like in the GUI mode.

Some bug titles are not immediately clear.

Example for a description:

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.

解决方案

You can use Violations Gradle Plugin to do that.

It can accumulate a bunch of report tools and present it nicely in the build log.

...
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    ║
╚════════════╧══════╧══════╧═══════╧═══════╝

这篇关于如何配置Gradle findbugs插件来提供bug的更多描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆