package cppcheck import ( "fmt" "strings" ) type Severity int const ( ERROR Severity = iota WARNING PORTABILITY PERFORMANCE STYLE INFORMATION DEBUG UNKNOWN ) func GetResult(records []Record, conf Conf) (string, int, error) { result := "### Test results summary\n\n" var severityCounts [UNKNOWN + 1]int score := conf.Score for _, record := range records { for _, match := range conf.Matches { for _, keyword := range match.Keywords { if strings.Contains(record.Id, keyword) { score -= match.Score } } } } result += fmt.Sprintf("1. error: %d\n", severityCounts[0]) result += fmt.Sprintf("2. warning: %d\n", severityCounts[1]) result += fmt.Sprintf("3. portability: %d\n", severityCounts[2]) result += fmt.Sprintf("4. performance: %d\n", severityCounts[3]) result += fmt.Sprintf("5. style: %d\n", severityCounts[4]) result += fmt.Sprintf("6. information: %d\n", severityCounts[5]) result += fmt.Sprintf("7. debug: %d\n", severityCounts[6]) return result, score, nil }