JOJ3/internal/parsers/clang_tidy/score.go
张佳澈520370910044 e133b13a84
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
feat(internal/executors/clang_tidy,-internal/parsers/clang_tidy,-cmd/joj3/main_test.go): Parsers and executors for clang-tidy
2024-05-01 00:18:09 +08:00

32 lines
678 B
Go

package clang_tidy
func Contains[T comparable](arr []T, element T) bool {
for i := range arr {
// TODO: The keyword in json report might also be an array, need to split it
// TODO: Might use string.Contains() rather than ==
if element == arr[i] {
return true
}
}
return false
}
func get_score(json_messages []json_message, conf Conf) int {
fullmark := conf.Score
for _, json_message := range json_messages {
keyword := json_message.Check_name
flag := false
for _, match := range conf.Matches {
if Contains(match.Keyword, keyword) {
fullmark -= match.Score
flag = true
break
}
}
if !flag {
fullmark -= 1
}
}
return fullmark
}