Skip to content

Commit

Permalink
add pmd, findbugs to gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
toadette committed Sep 20, 2016
1 parent 4089032 commit b1d014d
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
55 changes: 55 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,58 @@ afterEvaluate {
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}

apply plugin: 'pmd'

task pmd(type: Pmd, group: 'reporting', description: 'Inspect sourcecode for bugs') {
ruleSetFiles = files("pmd.xml")
ignoreFailures = true
ruleSets = []

source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/test/**'

reports {
xml.enabled = true
html.enabled = true
xml {
destination "$reportsDir/pmd/pmd.xml"
}
html {
destination "$reportsDir/pmd/pmd.html"
}
}
}

afterEvaluate {
if (project.tasks.findByName('check')) {
check.dependsOn('pmd')
}
}

apply plugin: 'findbugs'

task findbugs(type: FindBugs) {
ignoreFailures = true
classes = files('build/intermediates/classes/debug')
source = fileTree('src/main/java/')
classpath = files()
excludeFilter = new File("findbugs.xml")

effort = 'max'
reports {
xml.enabled = true
html.enabled = false
xml {
destination "$reportsDir/findbugs/findbugs.xml"
}
}
}

afterEvaluate {
if (project.tasks.findByName("check")) {
check.dependsOn('findbugs')
}
}
15 changes: 15 additions & 0 deletions findbugs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="~.*\.R\$.*"/>
</Match>
<Match>
<Class name="~.*\.Manifest\$.*"/>
</Match>
<Match>
<Class name="~.*\.*Test" />
<Not>
<Bug code="IJU" />
</Not>
</Match>
</FindBugsFilter>
42 changes: 42 additions & 0 deletions pmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Android Application Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">

<rule ref="rulesets/java/android.xml" />
<rule ref="rulesets/java/basic.xml" />
<rule ref="rulesets/java/braces.xml"/>
<rule ref="rulesets/java/clone.xml" />
<rule ref="rulesets/java/codesize.xml" />
<rule ref="rulesets/java/coupling.xml" >
<exclude name="LawOfDemeter"/>
<exclude name="LoosePackageCoupling"/>
</rule>
<rule ref="rulesets/java/design.xml" >
<exclude name="ImmutableField"/>
</rule>
<rule ref="rulesets/java/empty.xml" />
<rule ref="rulesets/java/finalizers.xml" />
<rule ref="rulesets/java/imports.xml">
<exclude name="TooManyStaticImports" />
</rule>
<rule ref="rulesets/java/logging-java.xml">
<exclude name="GuardLogStatementJavaUtil" />
</rule>

<rule ref="rulesets/java/strings.xml" />
<rule ref="rulesets/java/naming.xml">
<exclude name="AbstractNaming" />
<exclude name="LongVariable" />
<exclude name="ShortVariable"/>
<exclude name="ShortClassName"/>
<exclude name="ShortMethodName"/>
<exclude name="VariableNamingConventions" />
</rule>
<rule ref="rulesets/java/strictexception.xml" />
<rule ref="rulesets/java/sunsecure.xml" />
<rule ref="rulesets/java/typeresolution.xml" />
<rule ref="rulesets/java/unnecessary.xml" />
<rule ref="rulesets/java/unusedcode.xml" />
</ruleset>

0 comments on commit b1d014d

Please sign in to comment.