文档章节

Using the FindBugs™ Eclipse plugin

ForwardsHope
 ForwardsHope
发布于 2016/04/21 10:54
字数 866
阅读 102
收藏 0

#程序员薪资揭榜#你做程序员几年了?月薪多少?发量还在么?>>>

Using the FindBugs™ Eclipse plugin

Table of Contents

    1. Requirements
    1. Installation
    1. Using the Plugin
    1. Extending the Eclipse Plugin (since 2.0.0)
    1. Troubleshooting The FindBugs Eclipse plugin allows FindBugs to be used within the Eclipse IDE. The FindBugs Eclipse plugin was generously contributed by Peter Friese. Phil Crosby and Andrey Loskutov contributed major improvements to the plugin.

1. Requirements

To use the FindBugs Plugin for Eclipse, you need Eclipse 3.3 or later, and JRE/JDK 1.5 or later.

2. Installation

We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates. There are three different update sites

FindBugs Eclipse update sites

http://findbugs.cs.umd.edu/eclipse/

Only provides official releases of FindBugs.

http://findbugs.cs.umd.edu/eclipse-candidate/

Provides official releases and release candidates of FindBugs.

http://findbugs.cs.umd.edu/eclipse-daily/

Provides the daily build of FindBugs. No testing other than that it compiles.

You can also manually download the plugin from the following link: http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_3.0.1.20150306.zip?download. Extract it in Eclipse's "plugins" subdirectory. (So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_3.0.1.20150306/findbugs.png should be the path to the FindBugs logo.)

Once the plugin is extracted, start Eclipse and choose Help → About Eclipse Platform → Plug-in Details. You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project".

3. Using the Plugin

To get started, right click on a Java project in Package Explorer, and select the option labeled "Find Bugs". FindBugs will run, and problem markers (displayed in source windows, and also in the Eclipse Problems view) will point to locations in your code which have been identified as potential instances of bug patterns.

You can also run FindBugs on existing java archives (jar, ear, zip, war etc). Simply create an empty Java project and attach archives to the project classpath. Having that, you can now right click the archive node in Package Explorer and select the option labeled "Find Bugs". If you additionally configure the source code locations for the binaries, FindBugs will also link the generated warnings to the right source files.

You may customize how FindBugs runs by opening the Properties dialog for a Java project, and choosing the "Findbugs" property page. Options you may choose include:

Enable or disable the "Run FindBugs Automatically" checkbox. When enabled, FindBugs will run every time you modify a Java class within the project.

Choose minimum warning priority and enabled bug categories. These options will choose which warnings are shown. For example, if you select the "Medium" warning priority, only Medium and High priority warnings will be shown. Similarly, if you uncheck the "Style" checkbox, no warnings in the Style category will be displayed.

Select detectors. The table allows you to select which detectors you want to enable for your project.

4. Extending the Eclipse Plugin (since 2.0.0)

Eclipse plugin supports contribution of custom FindBugs detectors (see also AddingDetectors.txt for more information). There are two ways to contribute custom plugins to the Eclipse:

Existing standard FindBugs detector packages can be configured via Window → Preferences → Java → FindBugs → Misc. Settings → Custom Detectors. Simply specify there locations of any additional plugin libraries.

The benefit of this solution is that already existing detector packages can be used "as is", and that you can quickly verify the quality of third party detectors. The drawback is that you have to apply this settings in each new Eclipse workspace, and this settings can't be shared between team members.

It is possible to contribute custom detectors via standard Eclipse extensions mechanism.

Please check the documentation of the findBugsEclipsePlugin/schema/detectorPlugins.exsd extension point how to update the plugin.xml. Existing FindBugs detector plugins can be easily "extended" to be full featured FindBugs AND Eclipse detector plugins. Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and update your build scripts to not to override the MANIFEST.MF during the build.

The benefit of this solution is that for given (shared) Eclipse installation each team member has exactly same detectors set, and there is no need to configure anything anymore. The (really small) precondition is that you have to convert your existing detectors package to the valid Eclipse plugin. You can do this even for third-party detector packages. Another major differentiator is the ability to extend the default FindBugs classpath at runtime with required third party libraries (see AddingDetectors.txt for more information).

5. Troubleshooting

This section lists common problems with the plugin and (if known) how to resolve them.

If you see OutOfMemory error dialogs after starting FindBugs analysis in Eclipse, please increase JVM available memory: change eclipse.ini and add the lines below to the end of the file:

-vmargs
-Xmx1000m

Important: the configuration arguments starting with the line "-vmargs" must be last lines in the eclipse.ini file, and only one argument per line is allowed!

If you do not see any FindBugs problem markers (in your source windows or in the Problems View), you may need to change your Problems View filter settings. See http://findbugs.sourceforge.net/FAQ.html#q7 for more information.

Referance(http://findbugs.sourceforge.net/manual/eclipse.html)

© 著作权归作者所有

ForwardsHope
粉丝 6
博文 36
码字总数 6634
作品 0
南京
程序员
私信 提问
加载中

评论(0)

在Eclipse或MyEclipse中安装findbugs插件

在Eclipse或MyEclipse中安装findbugs插件 我们都知道,在Eclipse或MyEclipse(我用的8.0)中安装插件有两种方式,一种是在线安装,第二种是先下载插件然后在本地安装。 在这里我们先介绍第一种...

满风
2012/08/27
662
0
求解配置ant+findbugs问题

哪位大哥能指点一下配置ant+findbugs的问题,描述如下: 下图是我的findbugs存放的目录,lib下放的是findbugs-ant.jar,src准备方待测试的java源代码。 build.xml内容如下: 启动cmd,运行a...

qz
2013/12/13
2.4K
0
代码分析工具findbug简介和使用

FindBugs(http://findbugs.sourceforge.net/)版本1.1.1 简介:findbugs是一个在java程序中查找bug的程序,它查找bug模式的实例,也就是可能出错的代码实例,注意findbugs是检查java字节码,...

罗荣熙
2012/09/17
997
0
Findbugs+eclipse 排除个别校验

Findbugs检查出来的问题可以在message.xml(解压findbugs插件中findbugs-plugin.jar)中找到,通过具体的报错信息拿到对应的type类型,通过具体类型写排除该类型的xml后导入eclipse再重新通过...

osc_8j6k14dq
2019/09/12
2
0
idea安装findbugs及Find-sec-bugs安全组件

前序: FindBugs介绍:   FindBugs用来查找Java代码中的程序错误,它使用静态分析来识别Java程序中上百种不同类型的潜在错误。潜在错误可分为四个等级:恐怖的、吓人的、令人困扰的和值得关...

傻不拉几猫
03/05
0
0

没有更多内容

加载失败,请刷新页面

加载更多

如果我有jQuery背景,那么“ AngularJS中的思考”吗? [关闭]

问题: Closed . 已关闭 。 This question needs to be more focused . 这个问题需要更加集中 。 It is not currently accepting answers. 它当前不接受答案。 Want to improve this questio......

技术盛宴
20分钟前
9
0
ArrayList-不常用方法

这篇笔记主要记录一些不常用方法,了解一下可以干什么,有个印象。 改变数组容量 /** * 将该<tt> ArrayList </ tt>实例的容量调整为列表的当前大小。 * 应用程序可以使用此操作来最大程度...

jackdawl
24分钟前
4
0
PCDN+路由器就能赚钱? 揭秘京东云无线宝背后的黑科技

受疫情影响,今年视频直播、点播等在线视频业务迎来了爆发期,看视频成为人们宅在家中的主要消遣方式之一,由此带来的互联网流量增长大幅增加了对 CDN流量的消耗。传统CDN依赖于运营商、IDC...

京东智联云开发者
26分钟前
10
0
Oracle 中关于 group by 的那些坑

分组聚合Group by 在mysql中,对group by 的使用限制是比较宽松,还是比较灵活的, 表数据之间的调取是完全没问题的; 而在Oracle中,对group by 就有一定限制,两句相同的SQL语句,可能在mysql中不...

煌sir
42分钟前
20
0
MySQL服务器的SQL模式

与其它数据库不同,MySQL 服务器可以在不同的 SQL 模式下运行,并且可以针对不同的客户端以不同的方式应用这些模式,具体取决于 sql_mode 系统变量的值。 SQL 模式定义了 MySQL 数据库所支持...

Linux就该这么学
46分钟前
36
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部