简体   繁体   English

在eclipse中配置FindBugs

[英]Configuring FindBugs in eclipse

I want to use same configuration for FindBugs irrespective of whether it is executed form eclipse or ant build. 我想对FindBugs使用相同的配置,无论它是从eclipse还是ant build执行。

Using ant FindBugs task, it is possible to specify which classes FindBugs should analyze. 使用ant FindBugs任务,可以指定FindBugs应分析哪些类。 However, FindBugs eclipse plugin has no such option. 但是,FindBugs eclipse插件没有这样的选择。 It considers all classes in the buildpath. 它会考虑构建路径中的所有类。

Eg In case of maven based project the eclipse build path contains both application classes and test classes. 例如,对于基于maven的项目,eclipse构建路径包含应用程序类和测试类。 I want FindBugs eclipse plugin to not analyze test classes. 我希望FindBugs eclipse插件不分析测试类。 Is it possible? 可能吗?

Is there a way to customize FindBugs eclipse plugin to indicate classes to analyze? 有没有办法自定义FindBugs eclipse插件来指示要分析的类?

Thanks in advance. 提前致谢。

It doesn't seem possible, but you could create a second project referencing the same source files (sources only, not tests). 这似乎不可能,但您可以创建引用相同源文件的第二个项目(仅源,而不是测试)。

Findbugs would only be active with that second project, for you to inspect the result of a static code analysis. Findbugs只会在第二个项目中处于活动状态,以便您检查静态代码分析的结果。

You can specify exclusion filter for Java project via preferences -> filter. 您可以通过首选项 - >过滤器为Java项目指定排除过滤器。 The filter file is written in xml. 过滤器文件以xml编写。 See "Filters" chapter in FB manual: http://findbugs.sourceforge.net/manual/filter.html . 请参阅FB手册中的“过滤器”一章: http//findbugs.sourceforge.net/manual/filter.html

Since 2.0.3 one also can re-use Eclipse configuration with ant builds, see the help for "userPreferencesFile" ant option: http://findbugs.sourceforge.net/manual/anttask.html#d0e1339 从2.0.3开始,也可以使用ant构建重用Eclipse配置,请参阅“userPreferencesFile”ant选项的帮助: http ://findbugs.sourceforge.net/manual/anttask.html#d0e1339

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM