fix code review
This commit is contained in:
parent
a8e55fc0e8
commit
487291a54f
|
|
@ -12,6 +12,7 @@ local.properties
|
|||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
.gradle
|
||||
.idea
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -32,15 +32,11 @@ class ApiGeneratorAndroidPlugin : ApiGeneratorPlugin() {
|
|||
}
|
||||
tasks
|
||||
.filterIsInstance<KotlinCompile>()
|
||||
.forEach {
|
||||
it.source(outputDir)
|
||||
}
|
||||
.forEach { it.source(outputDir) }
|
||||
|
||||
tasks
|
||||
.filterIsInstance<JavaCompile>()
|
||||
.forEach {
|
||||
it.source(outputDir)
|
||||
}
|
||||
.forEach { it.source(outputDir) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@ class ApiGeneratorBackendPlugin : ApiGeneratorPlugin() {
|
|||
override fun apply(target: Project) {
|
||||
super.apply(target)
|
||||
|
||||
with(target) {
|
||||
val extension = getExtension()
|
||||
val extension = target.getExtension()
|
||||
|
||||
extension.outputDirPath = file("src/main/kotlin").path
|
||||
extension.recreateOutputDir = false
|
||||
extension.outputLanguage = OutputLanguage.KotlinServer
|
||||
extension.outputDirPath = target.file("src/main/kotlin").path
|
||||
extension.recreateOutputDir = false
|
||||
extension.outputLanguage = OutputLanguage.KotlinServer
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ abstract class ApiGeneratorPlugin : Plugin<Project> {
|
|||
companion object {
|
||||
const val API_GENERATOR_CONFIG = "apiGenerator"
|
||||
const val API_GENERATOR_EXT_NAME = "apiGenerator"
|
||||
const val API_GENERATOR_VERSION = "1.4.0-beta5"
|
||||
const val API_GENERATOR_DEFAULT_VERSION = "1.4.0-beta5"
|
||||
}
|
||||
|
||||
override fun apply(target: Project) {
|
||||
|
|
@ -29,7 +29,7 @@ abstract class ApiGeneratorPlugin : Plugin<Project> {
|
|||
configurations.create(API_GENERATOR_CONFIG)
|
||||
|
||||
dependencies {
|
||||
add(API_GENERATOR_CONFIG, "ru.touchin:api-generator:$API_GENERATOR_VERSION")
|
||||
add(API_GENERATOR_CONFIG, "ru.touchin:api-generator:$API_GENERATOR_DEFAULT_VERSION")
|
||||
}
|
||||
|
||||
extensions.create<ApiGeneratorExtension>(API_GENERATOR_EXT_NAME)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ class AndroidLintError(
|
|||
private val description: String
|
||||
) : StaticAnalysisError {
|
||||
|
||||
override fun print(count: Int): String = "\n$count. Android Lint. $description ($errorId)\n\tat [$filePath${fileLine?.let { ":$it" }.orEmpty()}]"
|
||||
override fun print(count: Int): String = "\n$count. Android Lint. $description ($errorId)\n\tat [$filePath$fileLinePrefix]"
|
||||
|
||||
private val fileLinePrefix: String
|
||||
get() = fileLine?.let { ":$it" }.orEmpty()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import static_analysis.errors.AndroidLintError
|
|||
import static_analysis.errors.StaticAnalysisError
|
||||
import static_analysis.plugins.StaticAnalysisExtension
|
||||
import static_analysis.utils.typedChildren
|
||||
import static_analysis.utils.xmlParser
|
||||
import xmlParser
|
||||
|
||||
class AndroidLinter : Linter {
|
||||
|
||||
|
|
@ -51,14 +51,18 @@ class AndroidLinter : Linter {
|
|||
}
|
||||
}
|
||||
|
||||
override fun getTaskNames(project: Project, buildType: String?): List<String> = project
|
||||
.subprojects
|
||||
.filter { it.plugins.hasPlugin(AppPlugin::class.java) }
|
||||
.mapNotNull { subproject: Project ->
|
||||
subproject.tasks.find { task ->
|
||||
task.name.contains(buildType!!, ignoreCase = true) && task.name.contains("lint")
|
||||
}?.path
|
||||
}
|
||||
override fun getTaskNames(project: Project, buildType: String?): List<String> {
|
||||
if (buildType == null) throw IllegalStateException("build type must not be null in android linter")
|
||||
|
||||
return project
|
||||
.subprojects
|
||||
.filter { it.plugins.hasPlugin(AppPlugin::class.java) }
|
||||
.mapNotNull { subproject: Project ->
|
||||
subproject.tasks.find { task ->
|
||||
task.name.contains(buildType, ignoreCase = true) && task.name.contains("lint")
|
||||
}?.path
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.getLintReportFile() = file("${rootProject.buildDir}/reports/lint-report.xml")
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import static_analysis.errors.StaticAnalysisError
|
|||
import static_analysis.plugins.StaticAnalysisExtension
|
||||
import static_analysis.utils.getSources
|
||||
import static_analysis.utils.typedChildren
|
||||
import static_analysis.utils.xmlParser
|
||||
import xmlParser
|
||||
|
||||
class CpdLinter : Linter {
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class CpdLinter : Linter {
|
|||
.rootProject
|
||||
.tasks
|
||||
.withType<Cpd>()
|
||||
.map { it.path }
|
||||
.map(Cpd::getPath)
|
||||
|
||||
private fun Project.getCpdReportFile() = file("${rootProject.buildDir}/reports/cpd.xml")
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import static_analysis.errors.StaticAnalysisError
|
|||
import static_analysis.plugins.StaticAnalysisExtension
|
||||
import static_analysis.utils.getSources
|
||||
import static_analysis.utils.typedChildren
|
||||
import static_analysis.utils.xmlParser
|
||||
import xmlParser
|
||||
|
||||
class DetektLinter : Linter {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package static_analysis.utils
|
||||
|
||||
import groovy.util.Node
|
||||
|
||||
fun Node.typedChildren() = children() as List<Node>
|
||||
|
|
@ -1,15 +1,9 @@
|
|||
package static_analysis.utils
|
||||
|
||||
import groovy.util.Node
|
||||
import groovy.util.XmlParser
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileTree
|
||||
import java.io.File
|
||||
|
||||
fun Node.typedChildren() = children() as List<Node>
|
||||
|
||||
fun xmlParser(file: File) = XmlParser().parse(file)
|
||||
|
||||
fun Project.getSources(excludes: String): FileTree = files(
|
||||
project
|
||||
.rootProject
|
||||
|
|
@ -12,10 +12,10 @@ object ReportGenerator {
|
|||
.map { linter -> linter to linter.getErrors(project) }
|
||||
|
||||
val lintersResults = groupedErrors
|
||||
.map { it.first.name to it.second.size }
|
||||
.map { (linter, linterErrors) -> linter.name to linterErrors.size }
|
||||
|
||||
val allErrors = groupedErrors
|
||||
.map { it.second }
|
||||
.map(Pair<Linter, List<StaticAnalysisError>>::second)
|
||||
.flatten()
|
||||
|
||||
val consoleReport = StringBuilder("\nSTATIC ANALYSIS ERRORS:").apply {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
import groovy.util.XmlParser
|
||||
import java.io.File
|
||||
|
||||
fun xmlParser(file: File) = XmlParser().parse(file)
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
-include rules/components.pro
|
||||
|
||||
-include rules/okhttp.pro
|
||||
-include rules/retrofit.pro
|
||||
-include rules/logansquare.pro
|
||||
|
|
@ -7,3 +6,4 @@
|
|||
-include rules/glide.pro
|
||||
-include rules/kaspersky.pro
|
||||
-include rules/appsflyer.pro
|
||||
-include rules/moshi.pro
|
||||
|
|
|
|||
Loading…
Reference in New Issue