detekt to plugin (#73)

* wip

https://plugins.gradle.org/plugin/io.gitlab.arturbosch.detekt

* wip

* wip

* done

* wip
This commit is contained in:
Maxim Bachinsky 2018-11-06 19:00:26 +03:00 committed by GitHub
parent b04f37c702
commit aac7e24674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 28 deletions

View File

@ -1,6 +1,7 @@
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'cpd' apply plugin: 'cpd'
apply plugin: 'pmd'
apply plugin: 'io.gitlab.arturbosch.detekt'
def getCpdTask def getCpdTask
def getPmdTask def getPmdTask
@ -17,18 +18,35 @@ def appendLintErrors
repositories { repositories {
maven { url "http://dl.bintray.com/touchin/touchin-tools" } maven { url "http://dl.bintray.com/touchin/touchin-tools" }
jcenter()
} }
configurations { configurations {
pngtastic pngtastic
detekt
} }
cpd { cpd {
skipLexicalErrors = true skipLexicalErrors = true
} }
detekt {
input = files("${rootDir}")
config = files("$buildScriptsDir/kotlin/detekt-config.yml")
// TODO add excludes from rootProject.extensions.findByName("staticAnalysisExcludes")
filters = ".*src/test.*,.*/resources/.*,.*/tmp/.*"
reports {
html {
enabled = true
destination = file("${project.buildDir}/reports/kotlin-detekt.html")
}
xml {
enabled = true
destination = file("${project.buildDir}/reports/kotlin-detekt.xml")
}
}
}
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
ext.getIdeaFormatTask = { isAndroidProject, sources -> ext.getIdeaFormatTask = { isAndroidProject, sources ->
@ -59,7 +77,7 @@ ext.getStaticAnalysisTaskNames = { isAndroidProject, sources ->
def tasksNames = new ArrayList<String>() def tasksNames = new ArrayList<String>()
try { try {
tasksNames.add(getCpdTask(isAndroidProject, sources)) tasksNames.add(getCpdTask(isAndroidProject, sources))
tasksNames.add(getKotlinDetektTask(isAndroidProject)) tasksNames.add(getKotlinDetektTask())
if (isAndroidProject) { if (isAndroidProject) {
tasksNames.add(getCheckstyleTask(sources)) tasksNames.add(getCheckstyleTask(sources))
tasksNames.add(getPmdTask(sources)) tasksNames.add(getPmdTask(sources))
@ -324,26 +342,8 @@ getCheckstyleTask = { sources ->
return taskName return taskName
} }
getKotlinDetektTask = { isAndroidProject -> getKotlinDetektTask = {
def taskName = (isAndroidProject ? "android" : "server") + "detektCheck_${project.name}" return "detekt"
tasks.create(taskName, JavaExec) {
main = "io.gitlab.arturbosch.detekt.cli.Main"
classpath = configurations.detekt
def input = "${rootDir}"
def output = "${project.buildDir}/reports"
def outputName = "kotlin-detekt"
def config = "$buildScriptsDir/kotlin/detekt-config.yml"
// TODO add excludes from rootProject.extensions.findByName("staticAnalysisExcludes")
def filters = ".*src/test.*,.*/resources/.*,.*/tmp/.*"
def params = ['-i', input,
'-o', output,
'-c', config,
'-f', filters,
'--output-name', outputName]
args(params)
}
return taskName
} }
task optimizePng { task optimizePng {
@ -368,6 +368,4 @@ dependencies {
checkstyle 'ru.touchin:checkstyle:7.6.2-fork' checkstyle 'ru.touchin:checkstyle:7.6.2-fork'
pngtastic 'com.github.depsypher:pngtastic:1.2' pngtastic 'com.github.depsypher:pngtastic:1.2'
}
detekt 'io.gitlab.arturbosch.detekt:detekt-cli:1.0.0.RC6-2'
}

View File

@ -349,4 +349,6 @@ style:
active: false active: false
WildcardImport: WildcardImport:
active: true active: true
excludeImports: 'java.util.*,kotlinx.android.synthetic.*' excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
MandatoryBracesIfStatements:
active: true