Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I print reported bugs to console in gradle findbugs plugin?

I am using Gradle FindBugs Plugin. How can I print reported bugs to console? PMD plugin has a consoleOutput property. Is there a similar property for FindBugs?

like image 751
memn Avatar asked Mar 11 '15 08:03

memn


2 Answers

As you can see here there's no such property or configuration possibility for FindBugs plugin. However it seems that the plugin can be customized in some way. E.g. by parsing and displaying the results.

See here and here.

like image 122
Opal Avatar answered Oct 14 '22 00:10

Opal


This is rudimentary ... but it's a start

task checkFindBugsReport << {
    def xmlReport = findbugsMain.reports.xml
    if (!xmlReport.destination.exists()) return;
    def slurped = new XmlSlurper().parse(xmlReport.destination)
    def report = ""
    slurped['BugInstance'].eachWithIndex { bug, index ->
        report += "${index + 1}. Found bug risk ${bug.@'type'} of category ${bug.@'category'} "
        report += "in the following places"
        bug['SourceLine'].each { place ->
            report += "\n       ${place.@'classname'} at lines ${place.@'start'}:${place.@'end'}"
        }
    }
    if (report.length() > 1) {
        logger.error "[FINDBUGS]\n ${report}"
    }
}

findbugsMain.finalizedBy checkFindBugsReport
like image 1
Markus T Avatar answered Oct 14 '22 02:10

Markus T