fix(parser/clangtidy): ignore empty lines
All checks were successful
build / build (push) Successful in 1m8s
build / trigger-build-image (push) Successful in 7s

This commit is contained in:
张泊明518370910136 2024-10-16 16:15:54 -04:00
parent e44537ea95
commit 7ff6dfb002
2 changed files with 7 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv" "strconv"
"strings"
) )
type Level int type Level int
@ -68,6 +69,9 @@ func levelFromString(levelString string) Level {
} }
func isIgnored(line string) bool { func isIgnored(line string) bool {
if strings.TrimSpace(line) == "" {
return true
}
ignoreRegex := regexp.MustCompile("^error:.*$") ignoreRegex := regexp.MustCompile("^error:.*$")
return ignoreRegex.MatchString(line) return ignoreRegex.MatchString(line)
} }

View File

@ -24,11 +24,6 @@ type ClangTidy struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
stdout := executorResult.Files["stdout"] stdout := executorResult.Files["stdout"]
stderr := executorResult.Files["stderr"] stderr := executorResult.Files["stderr"]
lines := strings.SplitAfter(stdout, "\n")
messages := ParseLines(lines, conf)
formattedMessages := Format(messages)
if executorResult.Status != stage.Status(envexec.StatusAccepted) { if executorResult.Status != stage.Status(envexec.StatusAccepted) {
if !((executorResult.Status == stage.Status(envexec.StatusNonzeroExitStatus)) && if !((executorResult.Status == stage.Status(envexec.StatusNonzeroExitStatus)) &&
(executorResult.ExitStatus == 1)) { (executorResult.ExitStatus == 1)) {
@ -41,6 +36,9 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
} }
} }
} }
lines := strings.SplitAfter(stdout, "\n")
messages := ParseLines(lines, conf)
formattedMessages := Format(messages)
score, comment := GetResult(formattedMessages, conf) score, comment := GetResult(formattedMessages, conf)
return stage.ParserResult{ return stage.ParserResult{
Score: score, Score: score,