clang-tidy parser and executor #26

Merged
张泊明518370910136 merged 26 commits from clang-tidy into master 2024-05-18 02:50:13 +08:00
3 changed files with 9 additions and 7 deletions
Showing only changes of commit 07ef611f95 - Show all commits

@ -1 +1 @@
Subproject commit 422868c1c6427ce73e665477b40922c72ccc14e5
Subproject commit 580d9c9e20ae887551af2f87483d82cf6efa6f6d

View File

@ -109,14 +109,14 @@ func group_messages(messages []ClangMessage) []ClangMessage {
return grouped_messages
}
func convert_paths_to_relative(messages *[]ClangMessage) {
currentDir := "/w"
func convert_paths_to_relative(messages *[]ClangMessage, conf Conf) {
currentDir := conf.RootDir
for i := range *messages {
(*messages)[i].filepath, _ = filepath.Rel(currentDir, (*messages)[i].filepath)
}
}
func parse_lines(lines []string) []ClangMessage {
func parse_lines(lines []string, conf Conf) []ClangMessage {
messages := make([]ClangMessage, 0)
for _, line := range lines {
if is_ignored(string(line)) {
@ -129,6 +129,6 @@ func parse_lines(lines []string) []ClangMessage {
messages = append(messages, message)
}
}
convert_paths_to_relative(&messages)
convert_paths_to_relative(&messages, conf)
return group_messages(messages)
}

View File

@ -14,7 +14,8 @@ type Match struct {
}
type Conf struct {
Score int
Score int `default:"100"`
RootDir string `default:"\\w"`
Matches []Match
}
@ -24,7 +25,7 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
stdout := executorResult.Files["stdout"]
lines := strings.SplitAfter(stdout, "\n")
messages := parse_lines(lines)
messages := parse_lines(lines, conf)
formatted_messages := format(messages)
// TODO: Handle the json file (parse into markdown and delete it?)
@ -36,6 +37,7 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
encoder.SetIndent("", " ")
_ = encoder.Encode(formatted_messages)
// TODO: Handle unexpected errors from executor
// if executorResult.Status != stage.Status(envexec.StatusAccepted) {
// return stage.ParserResult{
// Score: 0,