Android Studio 配置 FindBugs

简介

FindBugs 静态分析工具,检查类或者jar文件,将字节码与一组缺陷模式进行对比发现可能的问题。

bug 分为三个级别:low,medium,high。

bug种类:

  • Bad practice 坏的实践
  • Correctness 一般的正确性问题
  • Internationalization 国际化
  • Performance 性能问题
  • Dodgy 危险的
  • Malicious code vulnerability 可能受到的恶意攻击
  • Multithreaded correctness 多线程的正确性

使用方法

1、 Android Studio 中的setting-plugins里搜findbugs 选择 FindBugs-IDEA,安装这个插件。

2、装好之后在setting-other setting-findbugs-plugins里面勾选 for android 插件(Windows是在plugin中添加一个for android插件)和Reporting里面的High级别(先处理High级别的bug)。

3、最后在Filter中的Exclude filter files中添加findbugs-filter.xml文件。文件路径可根据自己去选择。

4、配置完之后,在Android Studio 下方的会有一个findbugs 工具栏,点击findbugs 工具栏,左侧会有一些检查方式:current file、changlist files 等等,点击就会有相应的检查操作了。

findbugs-filter.xml

<?xml version="1.0" encoding="UTF-8"?>

<FindBugsFilter>
    <!-- http://stackoverflow.com/questions/7568579/eclipsefindbugs-exclude-filter-files-doesnt-work -->
    <Match>
        <Class name="~.*\.R\$.*" />
    </Match>
    <Match>
        <Class name="~.*\.Manifest\$.*" />
    </Match>
    <!-- All bugs in test classes, except for JUnit-specific bugs -->
    <Match>
        <Class name="~.*\.*Test" />
        <Not>
            <Bug code="IJU" />
        </Not>
    </Match>
    <Match>
        <Package name="~com\.ali\.android\.app\.lib.*" />
    </Match>
    <Match>
        <Package name="~com\.asmack.*" />
    </Match>
    <Match>
        <Package name="~com\.alipay\.euler\.andfix.*" />
    </Match>
    <Match>
        <Package name="~com\.handmark\.pulltorefresh.*" />
    </Match>

</FindBugsFilter>
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值