32 lines
678 B
Go
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
|
|
}
|