MetroCS / QualityToolsForBlueJ

BlueJ extension to integrate quality assessment tools
GNU Lesser General Public License v3.0
0 stars 42 forks source link

[UserStory] Integrate SpotBugs into the build. #115

Open ghost opened 5 years ago

ghost commented 5 years ago

User Story

Essential components

Story

As a Developer I want SpotBugs to be integrated into the build so that I can perform static analysis quality checks to look for bugs in my code.

Acceptance Criteria

Supporting Information

Additional information on integrating SpotBugs in Gradle can be found here at gradle.org.

Dependencies

Depends On

Dependents

User story #104

ghost commented 5 years ago

Please assign this issue to @Bitked

alexrknowles commented 4 years ago

Please assign this issue to @alexrknowles

jody commented 4 years ago

Here's an example of a working gradle+SpotBugs implementation: https://github.com/daggerok/spotbugs-example It is using older versions of the tools, but may provide useful insights. I note that it works fine for me using Java 8 but that it failed with Java 11.

I just added Spotbugs to another project and it works under Java 11. That build.gradle file has this line added to plugins

id 'com.github.spotbugs' version '4.0.2'

a spotbugs configuration

spotbugs {
  toolVersion = '4.0.2'
  effort = 'max'
  reportLevel = 'low'
  reportsDir = file("$buildDir/reports/spotbugs")
  ignoreFailures = true
}

and a spotbugsMain configuration.

spotbugsMain {
    reports {
        html {
            enabled = true
            destination = file("$buildDir/reports/spotbugs/main.html")
            stylesheet = 'fancy-hist.xsl'
        }
    }
}

This seemed simple enough to be worth trying out for this project as well, so I tossed it into a build.xml and it seemed to work fine at first blush. Please check into this simple implementation and let me know if it's working for you as well.

It turns out that 4.0.2 is the most current version of SpotBugs!

alexrknowles commented 4 years ago

Thank you for the helpful info. I believe my spotbugs configuration was set up wrong. After making adjustments and including the spotbugsMain configuration, using "gradlew check" returns "build successful" after SpotBugs does its check. SpotBugs is also producing reports of any bugs found now.