From ffb6cbfc0ed9749de03b146892714ca3da591ed6 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Tue, 26 Jul 2022 11:50:06 +0300 Subject: [PATCH] Play around with PMD and checkstyle rules --- android-json-form-wizard/build.gradle | 48 ++++ checkstyle.xml | 333 ++++++++++++++++++++++++++ pmd-ruleset.xml | 146 +++++++++++ 3 files changed, 527 insertions(+) create mode 100644 checkstyle.xml create mode 100644 pmd-ruleset.xml diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle index 370df013e..c46236e68 100644 --- a/android-json-form-wizard/build.gradle +++ b/android-json-form-wizard/build.gradle @@ -12,6 +12,7 @@ buildscript { apply plugin: 'com.android.library' apply plugin: 'jacoco' apply plugin: 'com.github.kt3k.coveralls' +apply plugin: 'checkstyle' jacoco { toolVersion = "0.8.8" @@ -213,3 +214,50 @@ task javadoc(type: Javadoc) { classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile } + +task checkstyle(type: Checkstyle) { + description 'Check code standard' + group 'verification' + configFile file('../checkstyle.xml') + source 'src' + include '**/*.kt' + include '**/*.java' + exclude '**/gen/**' + classpath = files() + ignoreFailures = false +} + +/*apply plugin: 'findbugs' +task findbugs(type: FindBugs) { + ignoreFailures = false + effort = "max" + reportLevel = "low" + classes = files("$project.buildDir/intermediates/javac") + excludeFilter = file("$rootProject.rootDir/tools/findbugs-exclude.xml") + source = fileTree('src/main/java/') + classpath = files() + reports { + xml.enabled = false + html.enabled = true + html.destination file("$project.buildDir/outputs/findbugs/findbugs-output.html") + } +}*/ + +apply plugin: 'pmd' +task pmd(type: Pmd) { + ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml") + ignoreFailures = false + ruleSets = [] + source 'src' + include '**/*.kt' + include '**/*.java' + exclude '**/gen/**' + reports { + xml.enabled = false + html.enabled = true + html.destination = file("$project.buildDir/outputs/pmd/pmd.html") + } +} + + +println checkstyle.toolVersion diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 000000000..ea2694882 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pmd-ruleset.xml b/pmd-ruleset.xml new file mode 100644 index 000000000..90028c1cd --- /dev/null +++ b/pmd-ruleset.xml @@ -0,0 +1,146 @@ + + + + Custom rule-set for Android application + + .*/R.java + .*/gen/.* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +