spotbugs

SpotBugsのApache Mavenでの利用手順

step1SpotBugsのサイトにアクセス

SpotBugsとは、Javaのプログラムでバグを見つけるプログラムです。

2021年3月現在の最新バージョンは「4.2.0」です。

必要に応じてドキュメントを参照してください。

SpotBugs:https://spotbugs.readthedocs.io/ja/latest/introduction.html

spotbugs1

step2SpotBugsの利用手順

SpotBugsを使用する場合は、JDK「8以上」が必要です。

pom.xmlに以下の記述を行います。(ここでは最小限のものを紹介しますので、必要に応じて追記等してください。)

pom.xmlの例

:
<build>
<plugin>  
<groupId>com.github.spotbugs</groupId>  
<artifactId>spotbugs-maven-plugin</artifactId>  
<version>4.2.0</version>  
</plugin>  
</plugins>  
</build>
:
<reporting>
  <plugins>
    <plugin>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-maven-plugin</artifactId>
      <version>4.2.0</version>
    </plugin>
  </plugins>
</reporting>
:
<dependecies>

<dependency>  
<groupId>com.github.spotbugs</groupId>  
<artifactId>spotbugs-maven-plugin</artifactId>  
<version>4.2.0</version>  
</dependency>  
</dependencies>

pom.xmlに設定したら以下のコマンドで実行してください。

pom.xmlの例

> mvn compile site

すると、target/site/spotbugs.htmlにHTMLレポートが置かれるので、そちらを確認してください。

SpotBugs_report