Eclipse + FindBugs-排除过滤器文件不起作用 [英] Eclipse+FindBugs - exclude filter files doesn't work

查看:251
本文介绍了Eclipse + FindBugs-排除过滤器文件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows和带有ADT插件的Eclipse 3.7 Classic进行Android开发.

I'm using Windows and Eclipse 3.7 Classic with ADT plugin for Android development.

我刚刚安装了FindBugs,它在自动生成的R.java类中发现了一个错误.

I've just installed FindBugs and it have found a bug in auto-generated R.java class.

我想从FindBugs检查中排除此类.

I want to exclude this class from FindBugs checks.

我发现我可以在xml文件中为FindBugs定义排除过滤器,因此我创建了带有文本的文件D:\ Projects \ eclipse \ FindBugsExculde.xml

I've found that I can define exclude filters for FindBugs in xml file, so I've created a file D:\Projects\eclipse\FindBugsExculde.xml with text

<FindBugsFilter>
  <Match>
    <Class name="com.android.demo.notepad3.R$attr" />
  </Match>
</FindBugsFilter>

我已将此文件添加到Eclipse->窗口->首选项-> Java-> FindBugs->过滤文件->排除过滤文件"部分附近的添加..."按钮.

I've added this file to Eclipse -> Window -> Preferences -> Java -> FindBugs -> Filter files -> "Add..." button near the "Exclude filter files" section.

但是当我右键单击我的项目并选择查找错误"->查找错误"时,我仍然看到错误

But when I right-click on my project and select "Find Bugs" -> "Find Bugs" I still see the error

The class name com.android.demo.notepad3.R$attr doesn't start with an upper case letter

我什至试图替换

<Class name="com.android.demo.notepad3.R$attr" />

使用

<Class name="~.*" />

但仍然存在错误.

我试图重新启动Eclipse-运气不好.我什至以为FindBugs中可能存在Bug,因此它没有使用指定的文件,但是SysinternalsSuite的Procmon.exe显示它每次执行FindBugs时都会使用它:

I tried to restart Eclipse - no luck. I even thought that maybe there is a Bug in FindBugs so it doesn't use the file specified but Procmon.exe from SysinternalsSuite shows that it do use it each time I execute FindBugs:

ProcessName Operation   Path                                    Result
javaw.exe   QueryOpen   D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   QueryOpen   D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   CreateFile  D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   CreateFile  D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   QueryFileInternalInformationFile D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   CloseFile   D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   ReadFile    D:\Projects\eclipse\FindBugsExculde.xml SUCCESS
javaw.exe   CloseFile   D:\Projects\eclipse\FindBugsExculde.xml SUCCESS

我做错了什么?请帮帮我!

What am I doing wrong? Please help me!

推荐答案

遵循 FindBugs->过滤器文件->添加..."按钮以查找bug.我的第一个错误是我勾选了第一个复选框("include filter"(包括过滤器:-)部分).

Following the directives from Jenkins I created a findbugs-exclude.xml in my android workspace and added it via Eclipse -> Window -> Preferences -> Java -> FindBugs -> Filter files -> "Add..." button near the "Exclude filter files" section to findbugs. My first error was that I ticked the first checkbox (the include filter :-) section).

然后我开始手动查找bug,一切正常.我文件的内容是:

Then I started manually findbugs and everything was ok. The content of my file is:

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
    <Match>
        <Class name="~.*\.R\$.*"/>
    </Match>
    <Match>
    <Class name="~.*\.Manifest\$.*"/>
    </Match>
</FindBugsFilter>

我正在使用eclipse 3.7.1和findbugs 1.3.9.希望有帮助.

I am using eclipse 3.7.1 and findbugs 1.3.9. Hope that helps.

这篇关于Eclipse + FindBugs-排除过滤器文件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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