文档章节

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
eclipse/myeclipse配置*

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

cjun1990
2014/11/27
0
0
使用FindBugs插件提高代码质量和在重构中发现问题

FindBugs 是什么? FindBugs 是一个静态分析工具,它检查类或者 JAR 文件,将字节码与一组缺陷模式进行对比以发现可能的问题。之所以叫做静态分析工具,是因为它在不实际运行程序的情况对软件...

索隆
2012/06/05
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

流量劫持是如何产生的?

流量劫持,这种古老的攻击沉寂了一段时间后,最近又开始闹的沸沸扬扬。众多知名品牌的路由器相继爆出存在安全漏洞,引来国内媒体纷纷报道。只要用户没改默认密码,打开一个网页甚至帖子,路由...

谢思华
24分钟前
0
0
Hadoop Client无法使用maven下载源码

最近在学习hadoop,使用maven的时候想看一下源码的注释,结果IDEA一直提示无法下载 搞得我一度以为maven坏掉了。 但是通过搜索,发现在maven仓库里确实没有源码.... 而2.8.1以及之前的版本是...

Iceberg_XTY
25分钟前
0
0
为什么程序员千万不要重写代码?

你所做的事情,也许暂时看不到成果,但不要灰心或焦虑,你不是没有成长,而是在扎根。 图片来自网络 0 前言 程序员都有一颗工程师的心,所以当他们到一片新的场地想做的第一件事就是,将旧的...

Java小铺
27分钟前
0
0
VUE集成AdminLte

1. 安装需要到插件 npm i admin-lte -Snpm i jquery -Snpm i axios -Snpm i vue-router -S 2. 配置webpack.config.js 2.1 module.exports.module.rules修改字体loader: {test: /\.(p......

Pasenger
今天
0
0
Spring Aop原理之切点表达式解析

在前面的文章(Spring AOP切点表达式详解)中,我们总结了Spring Aop切点表达式的用法,而在上文(Spring Aop原理之Advisor过滤)中我们讲到,切点表达式的解析主要是在PatternParser.parse...

爱宝贝丶
今天
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部