mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-29 06:49:05 +08:00
Check various comment styles and wordings for autogenerated code
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
var (
|
||||
skipDirs = []string{"Godeps", "vendor", "third_party"}
|
||||
skipSuffixes = []string{".pb.go", ".pb.gw.go", ".generated.go", "bindata.go", "_string.go"}
|
||||
skipFirstLines = []string{"// code generated", "// generated", "/* generated", "/* code generated", "//generated", "/*generated"}
|
||||
skipFirstLines = []string{"code generated", "generated", "autogenerated", "@generated", "code autogenerated", "auto-generated"}
|
||||
)
|
||||
|
||||
func addSkipDirs(params []string) []string {
|
||||
@@ -95,9 +95,12 @@ func autoGenerated(fp string) bool {
|
||||
scanner := bufio.NewScanner(file)
|
||||
scanner.Scan()
|
||||
line := strings.ToLower(scanner.Text())
|
||||
commentStyles := []string{"// ", "//", "/* ", "/*"}
|
||||
for _, skip := range skipFirstLines {
|
||||
if strings.HasPrefix(line, skip) {
|
||||
return true
|
||||
for i := range commentStyles {
|
||||
if strings.HasPrefix(line, commentStyles[i]) && strings.HasPrefix(line[len(commentStyles[i]):], skip) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user