diff --git a/gradle/commonStaticAnalysis.gradle b/gradle/commonStaticAnalysis.gradle index 31589bc..951f7e3 100644 --- a/gradle/commonStaticAnalysis.gradle +++ b/gradle/commonStaticAnalysis.gradle @@ -1,6 +1,7 @@ apply plugin: 'checkstyle' -apply plugin: 'pmd' apply plugin: 'cpd' +apply plugin: 'pmd' +apply plugin: 'io.gitlab.arturbosch.detekt' def getCpdTask def getPmdTask @@ -17,18 +18,35 @@ def appendLintErrors repositories { maven { url "http://dl.bintray.com/touchin/touchin-tools" } - jcenter() } configurations { pngtastic - detekt } cpd { 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 ext.getIdeaFormatTask = { isAndroidProject, sources -> @@ -59,7 +77,7 @@ ext.getStaticAnalysisTaskNames = { isAndroidProject, sources -> def tasksNames = new ArrayList() try { tasksNames.add(getCpdTask(isAndroidProject, sources)) - tasksNames.add(getKotlinDetektTask(isAndroidProject)) + tasksNames.add(getKotlinDetektTask()) if (isAndroidProject) { tasksNames.add(getCheckstyleTask(sources)) tasksNames.add(getPmdTask(sources)) @@ -324,26 +342,8 @@ getCheckstyleTask = { sources -> return taskName } -getKotlinDetektTask = { isAndroidProject -> - def taskName = (isAndroidProject ? "android" : "server") + "detektCheck_${project.name}" - 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 +getKotlinDetektTask = { + return "detekt" } task optimizePng { @@ -368,6 +368,4 @@ dependencies { checkstyle 'ru.touchin:checkstyle:7.6.2-fork' pngtastic 'com.github.depsypher:pngtastic:1.2' - - detekt 'io.gitlab.arturbosch.detekt:detekt-cli:1.0.0.RC6-2' -} +} \ No newline at end of file diff --git a/kotlin/detekt-config.yml b/kotlin/detekt-config.yml index 757c24a..7914fd6 100644 --- a/kotlin/detekt-config.yml +++ b/kotlin/detekt-config.yml @@ -349,4 +349,6 @@ style: active: false WildcardImport: active: true - excludeImports: 'java.util.*,kotlinx.android.synthetic.*' \ No newline at end of file + excludeImports: 'java.util.*,kotlinx.android.synthetic.*' + MandatoryBracesIfStatements: + active: true \ No newline at end of file