update static plugin
This commit is contained in:
parent
4dfed1b2a8
commit
0748ec235b
|
|
@ -24,7 +24,9 @@ class StaticAnalysisAndroidPlugin : StaticAnalysisPlugin() {
|
|||
project.tasks.register("staticAnalysis") {
|
||||
setupStaticAnalysisTask(
|
||||
linters = linters,
|
||||
buildVariant = applicationVariants.first { it.name.contains("Debug") }.name
|
||||
buildVariant = applicationVariants
|
||||
.map { it.name.toLowerCase() }
|
||||
.first { it.contains("debug") }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -32,10 +34,14 @@ class StaticAnalysisAndroidPlugin : StaticAnalysisPlugin() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun createLinters(): List<Linter> = listOf(
|
||||
DetektLinter(),
|
||||
CpdLinter(),
|
||||
override fun createLinters(extension: StaticAnalysisExtension): List<Linter> = mutableListOf<Linter>().apply {
|
||||
add(DetektLinter())
|
||||
if (extension.isCpdLinterEnabled) {
|
||||
CpdLinter()
|
||||
}
|
||||
if (extension.isAndroidLinterEnabled) {
|
||||
AndroidLinter()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class StaticAnalysisBackendPlugin : StaticAnalysisPlugin() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun createLinters(): List<Linter> = listOf(
|
||||
override fun createLinters(extension: StaticAnalysisExtension): List<Linter> = listOf(
|
||||
CpdLinter(),
|
||||
DetektLinter()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,5 +2,7 @@ package static_analysis.plugins
|
|||
|
||||
open class StaticAnalysisExtension(
|
||||
var excludes: String = "",
|
||||
var buildScriptDir: String? = null
|
||||
var buildScriptDir: String? = null,
|
||||
var isCpdLinterEnabled: Boolean = true,
|
||||
var isAndroidLinterEnabled: Boolean = false,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package static_analysis.plugins
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
|
|
@ -24,9 +25,10 @@ abstract class StaticAnalysisPlugin : Plugin<Project> {
|
|||
|
||||
extensions.create<StaticAnalysisExtension>(STATIC_ANALYSIS_EXT_NAME)
|
||||
|
||||
val linters = createLinters()
|
||||
val initData: StaticAnalysisExtension = extensions.getByType()
|
||||
val linters = createLinters(initData)
|
||||
|
||||
linters.forEach { it.setupForProject(target, extensions.getByType()) }
|
||||
linters.forEach { it.setupForProject(target, initData) }
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
createStaticAnalysisTasks(target, linters)
|
||||
|
|
@ -39,7 +41,10 @@ abstract class StaticAnalysisPlugin : Plugin<Project> {
|
|||
dependsOn(*(linters.map { it.getTaskNames(project, buildVariant) }.flatten().toTypedArray()))
|
||||
}
|
||||
|
||||
abstract fun createLinters(): List<Linter>
|
||||
abstract fun createLinters(extension: StaticAnalysisExtension): List<Linter>
|
||||
abstract fun createStaticAnalysisTasks(project: Project, linters: List<Linter>)
|
||||
|
||||
fun Project.staticAnalysis(configure: Action<StaticAnalysisExtension>): Unit =
|
||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure(STATIC_ANALYSIS_EXT_NAME, configure)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ complexity:
|
|||
ignoreSingleWhenExpression: true
|
||||
ignoreSimpleWhenEntries: true
|
||||
LabeledExpression:
|
||||
active: true
|
||||
active: false
|
||||
LargeClass:
|
||||
active: true
|
||||
threshold: 800
|
||||
|
|
|
|||
Loading…
Reference in New Issue