SpotBugs(一):使用简介

前言

此文件将介绍在IDEA中使用SpotBugs的配置

一、SpotBugs是什么?

官方:https://spotbugs.github.io/

主要用途就是用来查找Java代码中的错误的程序,让我们的编码更加规范.

二、使用步骤

1.引入SpotBugs插件

代码如下(示例):

<build>
	<plugin>
	  <groupId>com.github.spotbugs</groupId>
	  <artifactId>spotbugs-maven-plugin</artifactId>
	  <version>4.5.3.0</version>
	  <executions>
	      <execution>
	          <id>check</id>
	          <phase>package</phase>
	          <goals>
	              <goal>check</goal>
	          </goals>
	      </execution>
	  </executions>
	  <dependencies>
	      <dependency>
	          <groupId>com.github.spotbugs</groupId>
	          <artifactId>spotbugs-annotations</artifactId>
	          <version>4.6.0</version>
	      </dependency>
	  </dependencies>
	</plugin>
</build>

2.使用Maven Helper插件

这里是我为了更加方便的执行maven打包等操作,也可以不安装
在这里插入图片描述
右键项目,添加命令:spotbugs:gui
这样就可以通过spotbugs提供的工具来图形化解析到时产生的xml报告
在这里插入图片描述

3.不使用使用Maven Helper插件

可以在idea的terminal中执行
在这里插入图片描述


结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42717117/article/details/123576813
今日推荐