Permalink
Browse files

add pmd, findbugs to gradle

  • Loading branch information...
toadette committed Sep 20, 2016
1 parent 4089032 commit b1d014d9da9013c478f1ad1cdcbd65b8e527e35e
Showing with 112 additions and 0 deletions.
  1. +55 −0 build.gradle
  2. +15 −0 findbugs.xml
  3. +42 −0 pmd.xml
View
@@ -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')
+ }
+}
View
@@ -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>
View
42 pmd.xml
@@ -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.