From d40bdd70badc899a14fbaf99ab6459177989338f Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sat, 9 Dec 2023 15:34:29 -0800 Subject: [PATCH] [build] Upgrade to spotbugs Gradle plugin 6.0.2 (#6027) --- build.gradle | 5 +- shared/java/javastyle.gradle | 150 ++++++++++++++++---------------- styleguide/spotbugs-exclude.xml | 6 ++ 3 files changed, 86 insertions(+), 75 deletions(-) diff --git a/build.gradle b/build.gradle index f1d2a522be..90c08c82ac 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ plugins { id 'net.ltgt.errorprone' version '3.1.0' apply false id 'com.github.johnrengelman.shadow' version '8.1.1' apply false id 'com.diffplug.spotless' version '6.20.0' apply false - id 'com.github.spotbugs' version '5.1.3' apply false + id 'com.github.spotbugs' version '6.0.2' apply false id 'com.google.protobuf' version '0.9.3' apply false } @@ -50,6 +50,9 @@ buildScan { publishAlways() } +import com.github.spotbugs.snom.Effort +ext.spotbugsEffort = Effort.MAX + ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt") if (project.hasProperty("publishVersion")) { diff --git a/shared/java/javastyle.gradle b/shared/java/javastyle.gradle index 5049efa48f..41ddb47e6d 100644 --- a/shared/java/javastyle.gradle +++ b/shared/java/javastyle.gradle @@ -1,83 +1,85 @@ -if (!project.hasProperty('skipJavaFormat')) { - apply plugin: 'checkstyle' +if (project.hasProperty('skipJavaFormat')) { + return; +} - checkstyle { - toolVersion = "10.12.2" - configDirectory = file("${project.rootDir}/styleguide") - config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml")) +apply plugin: 'checkstyle' + +checkstyle { + toolVersion = "10.12.2" + configDirectory = file("${project.rootDir}/styleguide") + config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml")) +} + +apply plugin: 'pmd' + +pmd { + toolVersion = '6.55.0' + consoleOutput = true + reportsDir = file("$project.buildDir/reports/pmd") + ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml")) + ruleSets = [] +} + +apply plugin: 'com.diffplug.spotless' + +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**', '**/bin/**', "src/generated/**" + } + toggleOffOn() + googleJavaFormat() + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() } - - apply plugin: 'pmd' - - pmd { - toolVersion = '6.55.0' - consoleOutput = true - reportsDir = file("$project.buildDir/reports/pmd") - ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml")) - ruleSets = [] + groovyGradle { + target fileTree('.') { + include '**/*.gradle' + exclude '**/build/**', '**/build-*/**', '**/bin/**' + } + greclipse() + indentWithSpaces(4) + trimTrailingWhitespace() + endWithNewline() } - - apply plugin: 'com.diffplug.spotless' - - spotless { - java { - target fileTree('.') { - include '**/*.java' - exclude '**/build/**', '**/build-*/**', '**/bin/**', "src/generated/**" - } - toggleOffOn() - googleJavaFormat() - removeUnusedImports() - trimTrailingWhitespace() - endWithNewline() - } - groovyGradle { - target fileTree('.') { - include '**/*.gradle' - exclude '**/build/**', '**/build-*/**', '**/bin/**' - } - greclipse() - indentWithSpaces(4) - trimTrailingWhitespace() - endWithNewline() - } - json { - target fileTree('.') { - include '**/*.json' - exclude '**/build/**', '**/build-*/**', '**/bin/**' - exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json' - } - gson() - .indentWithSpaces(2) - } - format 'xml', { - target fileTree('.') { - include '**/*.xml' - exclude '**/build/**', '**/build-*/**', '**/bin/**', '**/.idea/**', '**/.run/**' - } - eclipseWtp('xml') - trimTrailingWhitespace() - indentWithSpaces(2) - endWithNewline() - } - format 'misc', { - target fileTree('.') { - include '**/*.md', '**/.gitignore' - exclude '**/build/**', '**/build-*/**', '**/bin/**' - } - trimTrailingWhitespace() - indentWithSpaces(2) - endWithNewline() + json { + target fileTree('.') { + include '**/*.json' + exclude '**/build/**', '**/build-*/**', '**/bin/**' + exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json' } + gson() + .indentWithSpaces(2) } - - apply plugin: 'com.github.spotbugs' - - spotbugs { - ignoreFailures = false - effort = 'max' - excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml") + format 'xml', { + target fileTree('.') { + include '**/*.xml' + exclude '**/build/**', '**/build-*/**', '**/bin/**', '**/.idea/**', '**/.run/**' + } + eclipseWtp('xml') + trimTrailingWhitespace() + indentWithSpaces(2) + endWithNewline() } + format 'misc', { + target fileTree('.') { + include '**/*.md', '**/.gitignore' + exclude '**/build/**', '**/build-*/**', '**/bin/**' + } + trimTrailingWhitespace() + indentWithSpaces(2) + endWithNewline() + } +} + +apply plugin: 'com.github.spotbugs' + +spotbugs { + ignoreFailures = false + effort = spotbugsEffort + excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml") } task javaFormat { diff --git a/styleguide/spotbugs-exclude.xml b/styleguide/spotbugs-exclude.xml index f224099af6..9bee5c524d 100644 --- a/styleguide/spotbugs-exclude.xml +++ b/styleguide/spotbugs-exclude.xml @@ -1,5 +1,8 @@ + + + @@ -72,6 +75,9 @@ + + +