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>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值