文档章节

Using the FindBugs™ Eclipse plugin

Corlang
 Corlang
发布于 2016/04/21 10:54
字数 866
阅读 18
收藏 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)

© 著作权归作者所有

共有 人打赏支持
Corlang
粉丝 5
博文 34
码字总数 6634
作品 0
南京
高级程序员
在Eclipse或MyEclipse中安装findbugs插件

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

满风
2012/08/27
0
0
Eclipse-Java代码规范和质量检查插件-FindBugs

FindBugs 是由马里兰大学提供的一款开源 Java静态代码分析工具。FindBugs通过检查类文件或 JAR文件,将字节码与一组缺陷模式进行对比从而发现代码缺陷,完成静态代码分析。FindBugs既提供可视...

easonjim
2017/10/18
0
0
代码分析工具findbug简介和使用

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

罗荣熙
2012/09/17
0
0
findbugs eclipse 插件 及使用

1.下载 findbugs插件 地址:http://download.csdn.net/download/knightblackbob/9652590 edu.umd.cs.findbugs.plugin.eclipse_3.0.1.20150306-5afe4d1 解压到features中,重启eclipse 2.右击......

curiousby
2016/10/13
0
0
eclipse/myeclipse配置*

一、保存自己的工作窗口,在窗口的基础上新增自己需要的窗口,一般console/svn等窗口。 二、将eclipse所有的编码格式都设置为utf-8 如何为eclipse设置编码格式 三、配置查看文件所在的文件夹 ...

cjun1990
2014/11/27
0
0

没有更多内容

加载失败,请刷新页面

加载更多

初级开发-编程题

` public static void main(String[] args) { System.out.println(changeStrToUpperCase("user_name_abc")); System.out.println(changeStrToLowerCase(changeStrToUpperCase("user_name_abc......

小池仔
56分钟前
4
0
现场看路演了!

HiBlock
昨天
8
0
Rabbit MQ基本概念介绍

RabbitMQ介绍 • RabbitMQ是一个消息中间件,是一个很好用的消息队列框架。 • ConnectionFactory、Connection、Channel都是RabbitMQ对外提供的API中最基本的对象。Connection是RabbitMQ的s...

寰宇01
昨天
7
0
官方精简版Windows10:微软自己都看不过去了

微软宣布,该公司正在寻求解决方案,以减轻企业客户的Windows 10规模。该公司声称,企业客户下载整个Windows 10文件以更新设备既费钱又费时。 微软宣布,该公司正在寻求解决方案,以减轻企业...

linux-tao
昨天
8
0
TypeScript基础入门之JSX(二)

转发 TypeScript基础入门之JSX(二) 属性类型检查 键入检查属性的第一步是确定元素属性类型。 内在元素和基于价值的元素之间略有不同。 对于内部元素,它是JSX.IntrinsicElements上的属性类型...

durban
昨天
8
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部