Merge pull request #308 from TouchInstinct/setupLint_before_evaluate
Setup lint before evaluate
This commit is contained in:
commit
9babae50e5
|
|
@ -33,8 +33,8 @@ class AndroidLinter : Linter {
|
|||
.flatten()
|
||||
|
||||
override fun setupForProject(project: Project, extension: StaticAnalysisExtension) {
|
||||
project.gradle.projectsEvaluated {
|
||||
project.subprojects
|
||||
project.beforeEvaluate {
|
||||
subprojects
|
||||
.mapNotNull { it.extensions.findByType<AppExtension>() }
|
||||
.first()
|
||||
.lintOptions.apply {
|
||||
|
|
@ -45,8 +45,8 @@ class AndroidLinter : Linter {
|
|||
htmlReport = false
|
||||
isCheckDependencies = true
|
||||
disable("MissingConstraints", "VectorRaster")
|
||||
xmlOutput = project.getLintReportFile()
|
||||
lintConfig = project.file("${extension.buildScriptDir}/static_analysis_configs/lint.xml")
|
||||
xmlOutput = getLintReportFile()
|
||||
lintConfig = file("${extension.buildScriptDir}/static_analysis_configs/lint.xml")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,15 +34,18 @@ class CpdLinter : Linter {
|
|||
}
|
||||
|
||||
override fun setupForProject(project: Project, extension: StaticAnalysisExtension) {
|
||||
project.extensions.findByType<CpdExtension>()!!.apply {
|
||||
isSkipLexicalErrors = true
|
||||
language = "kotlin"
|
||||
minimumTokenCount = 60
|
||||
}
|
||||
project.tasks.withType<Cpd> {
|
||||
reports.xml.destination = project.getCpdReportFile()
|
||||
ignoreFailures = true
|
||||
source = project.getSources(extension.excludes)
|
||||
project.afterEvaluate {
|
||||
extensions.findByType<CpdExtension>()!!.apply {
|
||||
isSkipLexicalErrors = true
|
||||
language = "kotlin"
|
||||
minimumTokenCount = 60
|
||||
}
|
||||
tasks.withType<Cpd> {
|
||||
reports.xml.required.set(true)
|
||||
reports.xml.destination = getCpdReportFile()
|
||||
ignoreFailures = true
|
||||
source = getSources(extension.excludes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,27 +32,27 @@ class DetektLinter : Linter {
|
|||
.flatten()
|
||||
|
||||
override fun setupForProject(project: Project, extension: StaticAnalysisExtension) {
|
||||
project
|
||||
.tasks
|
||||
.withType(Detekt::class.java) {
|
||||
exclude("**/test/**")
|
||||
exclude("resources/")
|
||||
exclude("build/")
|
||||
exclude("tmp/")
|
||||
jvmTarget = "1.8"
|
||||
project.afterEvaluate {
|
||||
tasks.withType(Detekt::class.java) {
|
||||
exclude("**/test/**")
|
||||
exclude("resources/")
|
||||
exclude("build/")
|
||||
exclude("tmp/")
|
||||
jvmTarget = "1.8"
|
||||
|
||||
config.setFrom(project.files("${extension.buildScriptDir!!}/static_analysis_configs/detekt-config.yml"))
|
||||
reports {
|
||||
txt.enabled = false
|
||||
html.enabled = false
|
||||
xml {
|
||||
enabled = true
|
||||
destination = project.getDetektReportFile()
|
||||
}
|
||||
config.setFrom(files("${extension.buildScriptDir!!}/static_analysis_configs/detekt-config.yml"))
|
||||
reports {
|
||||
txt.enabled = false
|
||||
html.enabled = false
|
||||
xml {
|
||||
enabled = true
|
||||
destination = getDetektReportFile()
|
||||
}
|
||||
|
||||
source = project.getSources(extension.excludes)
|
||||
}
|
||||
|
||||
source = getSources(extension.excludes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTaskNames(project: Project, buildType: String?): List<String> = listOf(":detekt")
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ class StaticAnalysisAndroidPlugin : StaticAnalysisPlugin() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ abstract class StaticAnalysisPlugin : Plugin<Project> {
|
|||
|
||||
val linters = createLinters()
|
||||
|
||||
afterEvaluate {
|
||||
linters.forEach { it.setupForProject(target, extensions.getByType()) }
|
||||
}
|
||||
linters.forEach { it.setupForProject(target, extensions.getByType()) }
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
createStaticAnalysisTasks(target, linters)
|
||||
|
|
|
|||
Loading…
Reference in New Issue