简体   繁体   中英

FindBugs generate report in different formats

I am using FindBugs in order to generate some reports for a java project. I used the following command :

./findbugs-3.0.1/bin/findbugs -textui -high -nested:false -sortByClass -html -output h.html  -auxclasspath ../LabMetrics/operations/utilJars/junit.jar -auxclasspath ../LabMetrics/operations/utilJars/hamcrest-core-1.3.jar  ../LabMetrics/operations/target/classes

It works fine and a html report is generated. Also, when I am using this command: ./findbugs-3.0.1/bin/findbugs -textui -high -nested:false -sortByClass -output h.txt -auxclasspath ../LabMetrics/operations/utilJars/junit.jar -auxclasspath ../LabMetrics/operations/utilJars/hamcrest-core-1.3.jar ../LabMetrics/operations/target/classes the output will be redirected to h.txt file.

Now, I want to generate a html and a txt report running only a command. This action is time comsumming and I don t want to analyze twice the same code, only for obtaining the same report, but with different format. I searched on FindBugs site, but with no result. I really don`t want to parse html report source in order to build a txt report. There must be a way to get two reports in a single run.

It's better to create an XML first. XML contains all the necessary information and can be translated to whatever you need using some non-trivial command lines.

For example, assuming you have analysisResult.xml to produce txt report use

java -cp findbugs.jar edu.umd.cs.findbugs.PrintingBugReporter -txt analysisResult.xml >output.txt

To produce HTML report use

java -cp findbugs.jar edu.umd.cs.findbugs.PrintingBugReporter -html analysisResult.xml >output.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM