Skip to content

Commit

Permalink
Close camunda-community-hub#203: use spotbugs to identify possible co…
Browse files Browse the repository at this point in the history
…de problems

* added spotbugs gradle plugin
* added seperate job in GHA continous-integration that spotbugs analysis is always executed when a PR is created
* defined exclude rule that all generated classes beginning with $ are ignored
  • Loading branch information
arolfes committed Feb 16, 2021
1 parent 9f600bf commit 6a5cde7
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,29 @@ jobs:
${{ runner.os }}-gradle-
- name: Build with Gradle Wrapper
run: ./gradlew build --warning-mode=fail -Pmicronaut.runtime=${{ matrix.runtime }}

spotbugs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Set up JDKs with Matrix Build
uses: actions/setup-java@v1
with:
java-version: 8
- name: Cache Dependencies #see https://github.com/actions/cache/blob/master/examples.md#java---gradle
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-spotbugs-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-spotbugs-gradle-
- name: spotbugs
id: spotbugs_checks
run: ./gradlew spotbugsMain
- name: publish spotbugs
# TODO switch to orignial GHA when PR jwgmeligmeyling/spotbugs-github-action#10 is integrated
uses: arolfes/spotbugs-github-action@master
with:
path: '**/spotbugs/*.xml'
threshold: 0
5 changes: 5 additions & 0 deletions config/spotbugs/exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<FindBugsFilter>
<Match>
<Class name="~.*\.\$.*" />
</Match>
</FindBugsFilter>
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ camundaVersion=7.14.0
# Latest Jersey, that implements JAX-RS 2.1 API: see https://eclipse-ee4j.github.io/jersey/download.html
jerseyVersion=2.33
shadowJarVersion=6.1.0
spotbugsVersion=4.6.0
# Prevent upload of maven-metadata.xml.sha256/sha512 files to oss.sonatype.org
# see https://issues.sonatype.org/browse/OSSRH-53695?focusedCommentId=887733&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-887733
# see https://github.com/gradle/gradle/issues/11308#issuecomment-554317655
systemProp.org.gradle.internal.publish.checksums.insecure=true
org.gradle.parallel=true
org.gradle.parallel=true
21 changes: 21 additions & 0 deletions micronaut-camunda-bpm-feature/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.github.spotbugs.snom.Effort
plugins {
id("io.micronaut.library")
id("java-library")
Expand All @@ -6,6 +7,7 @@ plugins {
id("org.jetbrains.kotlin.plugin.allopen")
id("maven-publish")
id("signing")
id("com.github.spotbugs")
}

group = "info.novatec"
Expand Down Expand Up @@ -131,3 +133,22 @@ signing {
configurations {
testArtifacts
}

spotbugs {
ignoreFailures = true
effort = Effort.MAX
excludeFilter = file("${project.rootDir}/config/spotbugs/exclude.xml")
}
// Example to configure HTML report
spotbugsMain {
reports {
xml {
enabled = true
}
html {
enabled = false
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static class ServletContextInitializedListener implements ServletContextListener

protected static final EnumSet<DispatcherType> DISPATCHER_TYPES = EnumSet.of(REQUEST);

protected static ServletContext servletContext;
protected ServletContext servletContext;

@Override
public void contextInitialized(ServletContextEvent sce) {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pluginManagement {
id("com.github.johnrengelman.shadow") version "$shadowJarVersion"
id("io.micronaut.application") version "$micronautApplicationPluginVersion"
id("io.micronaut.library") version "$micronautLibraryPluginVersion"
id("com.github.spotbugs") version "$spotbugsVersion"
}
}

Expand Down

0 comments on commit 6a5cde7

Please sign in to comment.