feat(internal/parsers/clang_tidy): Added comments for clang-tidy parser
This commit is contained in:
		
							parent
							
								
									5c42a5f055
								
							
						
					
					
						commit
						061664eb70
					
				|  | @ -1 +1 @@ | ||||||
| Subproject commit 267f23cc74cea628850633dd39d7a1f37d7f7eb3 | Subproject commit bb8c33dc62742f7fc9f25ac91582fc4fa4ac3d5d | ||||||
|  | @ -47,7 +47,7 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { | ||||||
| 	// }
 | 	// }
 | ||||||
| 	return stage.ParserResult{ | 	return stage.ParserResult{ | ||||||
| 		Score:   get_score(formatted_messages, conf), | 		Score:   get_score(formatted_messages, conf), | ||||||
| 		Comment: "", | 		Comment: get_comment(formatted_messages), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,10 +1,14 @@ | ||||||
| package clang_tidy | package clang_tidy | ||||||
| 
 | 
 | ||||||
| func Contains[T comparable](arr []T, element T) bool { | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"strings" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func Contains(arr []string, element string) bool { | ||||||
| 	for i := range arr { | 	for i := range arr { | ||||||
| 		// TODO: The keyword in json report might also be an array, need to split it
 | 		// TODO: The keyword in json report might also be an array, need to split it
 | ||||||
| 		// TODO: Might use string.Contains() rather than ==
 | 		if strings.Contains(arr[i], element) { | ||||||
| 		if element == arr[i] { |  | ||||||
| 			return true | 			return true | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -24,3 +28,50 @@ func get_score(json_messages []json_message, conf Conf) int { | ||||||
| 	} | 	} | ||||||
| 	return fullmark | 	return fullmark | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func get_comment(json_messages []json_message) string { | ||||||
|  | 	res := "```\n### Test results summary\n\n" | ||||||
|  | 	keys := [...]string{ | ||||||
|  | 		"codequality-unchecked-malloc-result", | ||||||
|  | 		"codequality-no-global-variables", | ||||||
|  | 		"codequality-no-header-guard", | ||||||
|  | 		"codequality-no-fflush-stdin", | ||||||
|  | 		"readability-function-size", | ||||||
|  | 		"readability-identifier-naming", | ||||||
|  | 		"readability-redundant", | ||||||
|  | 		"readability-misleading-indentation", | ||||||
|  | 		"readability-misplaced-array-index", | ||||||
|  | 		"cppcoreguidelines-init-variables", | ||||||
|  | 		"bugprone-suspicious-string-compare", | ||||||
|  | 		"google-global-names-in-headers", | ||||||
|  | 		"clang-diagnostic", | ||||||
|  | 		"clang-analyzer", | ||||||
|  | 		"misc", | ||||||
|  | 		"performance", | ||||||
|  | 		"others", | ||||||
|  | 	} | ||||||
|  | 	mapping := map[string]int{} | ||||||
|  | 	for _, key := range keys { | ||||||
|  | 		mapping[key] = 0 | ||||||
|  | 	} | ||||||
|  | 	for _, json_message := range json_messages { | ||||||
|  | 		keyword := json_message.Check_name | ||||||
|  | 		flag := true | ||||||
|  | 		for key := range mapping { | ||||||
|  | 			if strings.Contains(keyword, key) { | ||||||
|  | 				mapping[key] += 1 | ||||||
|  | 				flag = false | ||||||
|  | 				break | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		if flag { | ||||||
|  | 			mapping["others"] += 1 | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	for i, key := range keys { | ||||||
|  | 		res = fmt.Sprintf("%s%d. %s: %d\n", res, i+1, key, mapping[key]) | ||||||
|  | 	} | ||||||
|  | 	res += "```" | ||||||
|  | 	return res | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user