Merge pull request #317 from TouchInstinct/ubrir_linters_fix

Ubrir linters fix
This commit is contained in:
Maksim Pozdeev 2022-08-04 16:11:49 +04:00 committed by GitHub
commit eb65ee351d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 17 deletions

View File

@ -14,23 +14,30 @@ class AndroidLinter : Linter {
override val name: String = "Android lint"
override fun getErrors(project: Project): List<StaticAnalysisError> = xmlParser(project.getLintReportFile())
.typedChildren()
.filter { it.name() == "issue" && (it.attribute("severity") as String) == "Error" }
.map { errorNode ->
errorNode
.typedChildren()
.filter { it.name() == "location" }
.map { locationNode ->
AndroidLintError(
filePath = locationNode.attribute("file") as String,
fileLine = locationNode.attribute("line") as String?,
errorId = errorNode.attribute("id") as String,
description = errorNode.attribute("message") as String
)
}
}
.flatten()
override fun getErrors(project: Project): List<StaticAnalysisError> {
val lintRepostFile = project.getLintReportFile()
return if (lintRepostFile.exists()) {
xmlParser(lintRepostFile)
.typedChildren()
.filter { it.name() == "issue" && (it.attribute("severity") as String) == "Error" }
.map { errorNode ->
errorNode
.typedChildren()
.filter { it.name() == "location" }
.map { locationNode ->
AndroidLintError(
filePath = locationNode.attribute("file") as String,
fileLine = locationNode.attribute("line") as String?,
errorId = errorNode.attribute("id") as String,
description = errorNode.attribute("message") as String
)
}
}
.flatten()
} else {
emptyList()
}
}
override fun setupForProject(project: Project, extension: StaticAnalysisExtension) {
project.beforeEvaluate {

View File

@ -39,6 +39,7 @@ class CpdLinter : Linter {
isSkipLexicalErrors = true
language = "kotlin"
minimumTokenCount = 60
encoding = "UTF-8"
}
tasks.withType<Cpd> {
reports.xml.required.set(true)