How to use findbugs in Apache Hadoop project

1967 단어 FindBugsMavenhadoop
This blog post is for Hadoop developers. It may be as a reference for you if you are not a Hadoop developer.

Detect findbugs warnings


$ mvn clean
$ mvn install -DskipTests
$ mvn findbugs:findbugs

You can see the following message if there are some findbugs warnings
[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Hadoop Data Join 3.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- findbugs-maven-plugin:3.0.0:findbugs (default-cli) @ hadoop-datajoin ---
[INFO] Fork Value is true
     [java] Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
     [java] Warnings generated: 2
[INFO] Done FindBugs Analysis....

View the warnings via GUI



If there are findbugs warnings in hadoop-datajoin module, do the following:
$ cd hadoop-tools/hadoop-datajoin
$ mvn findbugs:gui



Open a window as the above screenshot. You can easily detect the code which causes findbugs warnings.

Output HTML



When findbugs:findbugs is executed, the output is XML. It is difficult to know what the warnings are by reading the XML file. Nothing to worry about, we can easily convert the XML file to HTML so that we can know what Unlike gui, we can attach the file in JIRA to share the problem.

Prequisites: findbugs is installed and $FINDBUGS_HOME is set appropriately.
$ $FINDBUGS_HOME/bin/convertXmlToText -html target/findbugsXml.xml target/findbugsHtml.html

Summary


findbugs:gui is very useful.

좋은 웹페이지 즐겨찾기