文档章节

Using the FindBugs™ Eclipse plugin

Corlang
 Corlang
发布于 2016/04/21 10:54
字数 866
阅读 18
收藏 0
点赞 1
评论 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
博文 33
码字总数 6634
作品 0
南京
高级程序员
Eclipse-Java代码规范和质量检查插件-FindBugs

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

easonjim ⋅ 2017/10/18 ⋅ 0

Java静态检测工具/Java代码规范和质量检查简单介绍(转)

静态检查: 静态测试包括代码检查、静态结构分析、代码质量度量等。它可以由人工进行,充分发挥人的逻辑思维优势,也可以借助软件工具自动进行。代码检查代码检查包括代码走查、桌面检查、代...

easonjim ⋅ 2017/10/18 ⋅ 0

Jenkins的详细安装及使用

Jenkins的详细安装及使用 置顶2018年02月27日 10:20:43 阅读数:13578 操作环境:Windows 一、环境准备 1 安装JDK 本文采用jdk-8u111-windows-x64.exe; 2 配置tomcat 本文采用tomcat8,无需...

keppy ⋅ 05/25 ⋅ 0

Jenkins+SonarQube6.5.5+SonarScanner2.5代码质量管理平台

Jenkins+SonarQube6.5.5+SonarScanner2.5代码质量管理平台 简介 Sonar是一个用于代码质量管理的开源平台,用于管理Java源代码的质量。通过插件机制,Sonar 可以集成不同的测试工具,代码分析...

awesome@qa ⋅ 05/16 ⋅ 0

hadoop-2.6.4集群编译搭建-阿里云和腾讯云

腾讯云阿里云 hadoop集群编译搭建 环境准备 阿里云配置: 腾讯云配置: 创建用户 useradd hadoop passwd haddop jdk1.7安装: 下载:http://www.oracle.com/technetwork/java/javase/downloa...

lizer2016 ⋅ 2016/07/31 ⋅ 0

java中遍历map的四种方法

1、最常见的并且在大多数情况下也是最可取的遍历方式 键值都需要时使用 2、for-each循环中遍历keys或values 通过keySet或values来实现遍历,而不是用entrySet 比entrySet遍历在性能上稍好(快...

职业搬砖20年 ⋅ 06/13 ⋅ 0

FindBugs、PMD和CheckStyle对比

工具 目的 检查项 FindBugs 检查.class 基于Bug Patterns概念,查找javabytecode(.class文件)中的潜在bug。 它使用静态分析方法标识出Java程序中上百种潜在的不同类型的错误。 主要检查byt...

awesome@qa ⋅ 05/16 ⋅ 0

代码质量管理的开源平台Sonar QQ群522720170

点击链接加入QQ群 522720170(免费公开课、视频应有尽有):https://jq.qq.com/?wv=1027&k=5C08ATe 介绍 Sonar是一个用于代码质量管理的开源平台,用于管理Java源代码的质量。通过插件机制,...

小强测试帮 ⋅ 05/09 ⋅ 0

基于Sonar推动DevOps流程中的代码质量优化

1、DevOps DevOps逐渐成为开发运维领域的一种趋势,对DevOps 的定义有很多种,但“自动化” 很可能是该定义的一部分。Continuous Integration(CI,持续集成)、Continuous Delivery(CD,持...

陈能技 ⋅ 2016/03/22 ⋅ 0

代码质量管理的开源平台Sonar

点击链接加入QQ群 522720170(免费公开课、视频应有尽有):https://jq.qq.com/?wv=1027&k=5C08ATe 介绍 Sonar是一个用于代码质量管理的开源平台,用于管理Java源代码的质量。通过插件机制,...

小强测试帮 ⋅ 05/17 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

面试-JVM 内存结构

JVM 内存结构

秋日芒草 ⋅ 2分钟前 ⋅ 0

马氏距离与欧氏距离

马氏距离 马氏距离也可以定义为两个服从同一分布并且其协方差矩阵为Σ的随机变量之间的差异程度。 如果协方差矩阵为单位矩阵,那么马氏距离就简化为欧氏距离,如果协方差矩阵为对角阵,则其也...

漫步当下 ⋅ 25分钟前 ⋅ 0

聊聊spring cloud的RequestRateLimiterGatewayFilter

序 本文主要研究一下spring cloud的RequestRateLimiterGatewayFilter GatewayAutoConfiguration @Configuration@ConditionalOnProperty(name = "spring.cloud.gateway.enabled", matchIfMi......

go4it ⋅ 57分钟前 ⋅ 0

Spring JavaConfig 注解

JavaConfig注解允许开发者将Bean的定义和配置放在Java类中。它是除使用XML文件定义和配置Bean外的另一种方案。 配置: 如一个Bean如果在XML文件可以这样配置: <bean id="helloBean" class="...

霍淇滨 ⋅ 今天 ⋅ 0

Spring clound 组件

Spring Cloud技术应用从场景上可以分为两大类:润物无声类和独挑大梁类。 润物无声,融合在每个微服务中、依赖其它组件并为其提供服务。 Ribbon,客户端负载均衡,特性有区域亲和、重试机制。...

英雄有梦没死就别停 ⋅ 今天 ⋅ 0

Confluence 6 重新获得站点备份文件

Confluence 将会创建备份,同时压缩 XML 文件后存储熬你的 <home-directory>/backups> 目录中。你需要自己访问你安装的 Confluence 服务器,并且从服务器上获得这个文件。 运行从 Confluence...

honeymose ⋅ 今天 ⋅ 0

informix的常用SQL语句

1、创建数据库 eg1. 创建不记录日志的库testdb,参考语句如下: CREATE DATABASE testdb; eg2. 创建带缓冲式的记录日志的数据库testdb(SQL语句不一定在事务之中,拥有者名字不被用于对象的解...

wangxuwei ⋅ 今天 ⋅ 0

matplotlib画图

最简单的入门是从类 MATLAB API 开始,它被设计成兼容 MATLAB 绘图函数。 from pylab import *from numpy import *x = linspace(0, 5, 10)y = x ** 2figure()plot(x, y, 'r')...

Dr_hu ⋅ 今天 ⋅ 0

RabbitMQ学习以及与Spring的集成(三)

本文介绍RabbitMQ与Spring的简单集成以及消息的发送和接收。 在RabbitMQ的Spring配置文件中,首先需要增加命名空间。 xmlns:rabbit="http://www.springframework.org/schema/rabbit" 其次是模...

onedotdot ⋅ 今天 ⋅ 0

JAVA实现仿微信红包分配规则

最近过年发红包拜年成为一种新的潮流,作为程序猿对算法的好奇远远要大于对红包的好奇,这里介绍一种自己想到的一种随机红包分配策略,还请大家多多指教。 算法介绍 一、红包金额限制 对于微...

小致dad ⋅ 今天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部