Browse Source

Incorporated Checkstyle, findbugs, pmd and lint

pull/321/head
Jubril Edu 5 years ago
parent
commit
af1a61960b
  1. 64
      build.gradle
  2. 6
      checkstyle.xml
  3. 8
      findbugs-filter.xml
  4. 24
      pmd-ruleset.xml
  5. 4
      suppressions.xml

64
build.gradle

@ -15,6 +15,9 @@ buildscript {
}
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
ext {
supportLibraryVersion = '23.4.0'
@ -41,12 +44,10 @@ dependencies {
compile "com.android.support:cardview-v7:${supportLibraryVersion}"
compile 'com.getbase:floatingactionbutton:1.10.1'
/// dependencies for local unit tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
/// dependencies for instrumented tests
// JUnit4 Rules
androidTestCompile 'com.android.support.test:rules:0.5'
@ -73,6 +74,12 @@ tasks.withType(Test) {
}
android {
lintOptions {
abortOnError true
lintConfig file("${project.rootDir}/lint.xml")
htmlReport true
htmlOutput file("$project.buildDir/reports/lint/lint.html")
}
compileSdkVersion 23
buildToolsVersion "23.0.3"
@ -100,14 +107,12 @@ android {
assets.srcDirs = ['assets']
}
// move whole local unit tests structure as a whole from src/test/* to test/*
test.setRoot('test')
// move whole instrumented tests structure as a whole from src/androidTest/* to androidTest/*
androidTest.setRoot('androidTest')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
@ -131,4 +136,55 @@ android {
exclude 'META-INF/LICENSE.txt'
}
task checkstyle(type: Checkstyle) {
configFile = file("${rootProject.projectDir}/checkstyle.xml")
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
source 'src'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
}
task pmd(type: Pmd) {
ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
ignoreFailures = false
ruleSets = []
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
xml {
destination "$project.buildDir/reports/pmd/pmd.xml"
}
html {
destination "$project.buildDir/reports/pmd/pmd.html"
}
}
}
task findbugs(type: FindBugs) {
ignoreFailures = false
effort = "max"
reportLevel = "high"
classes = files("$project.buildDir/intermediates/classes")
excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
html {
destination "$project.buildDir/reports/findbugs/findbugs.html"
}
}
classpath = files()
}
check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
}

6
checkstyle.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
</module>

8
findbugs-filter.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="~.*\.Manifest\$.*"/>
</Match>
</FindBugsFilter>

24
pmd-ruleset.xml

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Android"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
The ruleset file checks code using rules defined below, new rules can always be added.The
pmd.html file contains the report which includes perceived coding issues
</description>
<exclude-pattern>.*/R.java</exclude-pattern>
<exclude-pattern>.*/gen/.*</exclude-pattern>
<rule ref="rulesets/java/logging-java.xml" />
<rule ref="rulesets/java/braces.xml" />
<rule ref="rulesets/java/strings.xml" />
<rule ref="rulesets/java/basic.xml" />
<rule ref="rulesets/java/naming.xml">
<exclude name="AbstractNaming" />
<exclude name="LongVariable" />
<exclude name="ShortMethodName" />
<exclude name="ShortVariable" />
<exclude name="VariableNamingConventions" />
</rule>
</ruleset>

4
suppressions.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<suppressions>
</suppressions>
Loading…
Cancel
Save