Skip to content

Instantly share code, notes, and snippets.

@patrickhammond
Created January 22, 2015 19:06
Show Gist options
  • Save patrickhammond/aa3515e494164dbfdae6 to your computer and use it in GitHub Desktop.
Save patrickhammond/aa3515e494164dbfdae6 to your computer and use it in GitHub Desktop.
FindBugs snippet
...
apply plugin: 'findbugs'
...
task findbugs(type: FindBugs, dependsOn: assembleDebug) {
excludeFilter file("${project.rootDir}/config/findbugs/exclude.xml")
classes = fileTree('build/intermediates/classes/debug/') // Varies based on your app build configs and flavors...
source = fileTree('src/main/java/')
classpath = files()
effort = 'max'
reports {
xml.enabled = false
html.enabled = true
}
}
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<!-- http://stackoverflow.com/questions/7568579/eclipsefindbugs-exclude-filter-files-doesnt-work -->
<Match>
<Class name="~.*\.R\$.*"/>
</Match>
<Match>
<Class name="~.*\.Manifest\$.*"/>
</Match>
<!-- All bugs in test classes, except for JUnit-specific bugs -->
<Match>
<Class name="~.*\.*Test" />
<Not>
<Bug code="IJU" />
</Not>
</Match>
</FindBugsFilter>

./gradlew app:findbugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment