JOJ3/internal/parsers/clang_tidy/score.go

27 lines
612 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
for _, match := range conf.Matches {
if Contains(match.Keyword, keyword) {
fullmark -= match.Score
break
}
}
}
return fullmark
}