Skip to content

Commit

Permalink
fix regex to get a list of linters (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil42Russia committed Nov 17, 2021
1 parent 836ce29 commit 1769529
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/kotlin/com/ypwang/plugin/GolangCiOutputParser.kt
Expand Up @@ -35,8 +35,8 @@ object GolangCiOutputParser {

val linters = mutableListOf<GoLinter>()
val linterRaw = result.stdout.lines()
// format: name[ (aka)]: description [fast: bool, auto-fix: bool]
val regex = Regex("""(?<name>\w+)( \((?<aka>[\w, ]+)\))?: (?<description>.+) \[fast: (?<fast>true|false), auto-fix: (?<autofix>true|false)]""")
// format: name[ (aka)][ deprecated]: description [fast: bool, auto-fix: bool]
val regex = Regex("""(?<name>\w+)( \((?<aka>[\w, ]+)\))?( \[(?<deprecated>deprecated)])?: (?<description>.+) \[fast: (?<fast>true|false), auto-fix: (?<autofix>true|false)]""")
// parse output
var enabled = true
for (line in linterRaw) {
Expand All @@ -57,9 +57,11 @@ object GolangCiOutputParser {
enabled,
it.groups["name"]!!.value,
it.groups["aka"]?.value ?: "",
it.groups["deprecated"]?.value == "deprecated",
it.groups["description"]!!.value,
it.groups["fast"]!!.value.toBoolean(),
it.groups["autofix"]!!.value.toBoolean())
it.groups["autofix"]!!.value.toBoolean(),
)
)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/ypwang/plugin/model/GoLinter.kt
Expand Up @@ -4,6 +4,7 @@ data class GoLinter (
val defaultEnabled: Boolean,
val name: String,
val aka: String,
val isDeprecated: Boolean,
val description: String,
val fast: Boolean,
val autoFix: Boolean
Expand Down

0 comments on commit 1769529

Please sign in to comment.