From 5de4c3ee78c1fd75c05cce37d4f38df063e6693c Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Fri, 1 Nov 2024 03:13:38 -0400 Subject: [PATCH] feat(parser): unify default init score = 0 (#73) --- internal/parser/clangtidy/parser.go | 2 +- internal/parser/cppcheck/parser.go | 2 +- internal/parser/keyword/parser.go | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/parser/clangtidy/parser.go b/internal/parser/clangtidy/parser.go index 35ae6f5..388715c 100644 --- a/internal/parser/clangtidy/parser.go +++ b/internal/parser/clangtidy/parser.go @@ -14,7 +14,7 @@ type Match struct { } type Conf struct { - Score int `default:"100"` + Score int RootDir string `default:"/w"` Matches []Match Stdout string `default:"stdout"` diff --git a/internal/parser/cppcheck/parser.go b/internal/parser/cppcheck/parser.go index f6606ce..0630d38 100644 --- a/internal/parser/cppcheck/parser.go +++ b/internal/parser/cppcheck/parser.go @@ -17,7 +17,7 @@ type Match struct { } type Conf struct { - Score int `default:"100"` + Score int Matches []Match Stdout string `default:"stdout"` Stderr string `default:"stderr"` diff --git a/internal/parser/keyword/parser.go b/internal/parser/keyword/parser.go index 57ca967..d6467e5 100644 --- a/internal/parser/keyword/parser.go +++ b/internal/parser/keyword/parser.go @@ -13,7 +13,8 @@ type Match struct { } type Conf struct { - FullScore int + Score int + FullScore int // TODO: remove me MinScore int Files []string ForceQuitOnMatch bool @@ -25,7 +26,7 @@ type Keyword struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) ( stage.ParserResult, bool, ) { - score := conf.FullScore + score := conf.Score comment := "" matched := false for _, file := range conf.Files { @@ -54,6 +55,10 @@ func (*Keyword) Run(results []stage.ExecutorResult, confAny any) ( if err != nil { return nil, true, err } + // TODO: remove me on FullScore field removed + if conf.FullScore != 0 && conf.Score == 0 { + conf.Score = conf.FullScore + } var res []stage.ParserResult forceQuit := false for _, result := range results {