FindBugsFilter的用法
Posted wpyily
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FindBugsFilter的用法相关的知识,希望对你有一定的参考价值。
findbugs执行扫描的时候会把不想检查的文件都检查一遍,比较耗时也没有参考价值。于是用到了filter功能,命令行就是:
findbugs -textui -exclude d:\\filter.xml -html -output d:\\test.html D:\\workspace\\androidDemo
常见的参数可以参考官方文档: 文档地址
列出需要用的一些参数:
-home 定义findbugs2软件存放位置
-low 提交警告及任何级别以上报告
-medium 提交中,高级报告(默认)
-high 只提交高级警告
-xml 警告以 xml输出
-html 警告以 html输出
-output 定义输出的文件名
-onlyAnalyze 只分析指定的 class/package
-exclude 忽略指定的 class/package (以xml定义过滤的命名)
-include 只输出指定的 class/package (以xml定义过滤的命名)
filter.xml的设置参考如下:
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<!-- android-support-v4.jar:包过滤 -->
<Match>
<Package name="~android\\.support\\.v4.*" />
</Match>
<!-- 类过滤、方法 -->
<Match>
<Class name="com.opencdk.MusicActivity" />
<Method name="getMusicName" />
</Match>
<Match>
<Class name="com.opencdk.VideoActivity" />
</Match>
<!-- Match all doublecheck violations in these methods of "AnotherClass". -->
<Match>
<Class name="com.opencdk.AnotherClass" />
<Or>
<Method name="nonOverloadedMethod" />
<Method name="frob" params="int,java.lang.String" returns="void" />
<Method name="blat" params="" returns="boolean" />
</Or>
<Bug code="DC" />
</Match>
<!-- All bugs in test classes, except for JUnit-specific bugs -->
<Match>
<Class name="~.*\\.*Test" />
<Not>
<Bug code="IJU" />
</Not>
</Match>
</FindBugsFilter>
以上是关于FindBugsFilter的用法的主要内容,如果未能解决你的问题,请参考以下文章