@@ -31,54 +31,80 @@ var replacePatterns = []replacePattern{
31
31
{`^composites: (\S+) composite literal uses unkeyed fields$` , "composites: `${1}` composite literal uses unkeyed fields" },
32
32
33
33
// gosec
34
- {`^(\S+): Blacklisted import (\S+): weak cryptographic primitive$` ,
35
- "${1}: Blacklisted import `${2}`: weak cryptographic primitive" },
34
+ {
35
+ `^(\S+): Blacklisted import (\S+): weak cryptographic primitive$` ,
36
+ "${1}: Blacklisted import `${2}`: weak cryptographic primitive" ,
37
+ },
36
38
{`^TLS InsecureSkipVerify set true.$` , "TLS `InsecureSkipVerify` set true." },
37
39
38
40
// gosimple
39
41
{`should replace loop with (.*)$` , "should replace loop with `${1}`" },
40
- {`should use a simple channel send/receive instead of select with a single case` ,
41
- "should use a simple channel send/receive instead of `select` with a single case" },
42
- {`should omit comparison to bool constant, can be simplified to (.+)$` ,
43
- "should omit comparison to bool constant, can be simplified to `${1}`" },
42
+ {
43
+ `should use a simple channel send/receive instead of select with a single case` ,
44
+ "should use a simple channel send/receive instead of `select` with a single case" ,
45
+ },
46
+ {
47
+ `should omit comparison to bool constant, can be simplified to (.+)$` ,
48
+ "should omit comparison to bool constant, can be simplified to `${1}`" ,
49
+ },
44
50
{`should write (.+) instead of (.+)$` , "should write `${1}` instead of `${2}`" },
45
51
{`redundant return statement$` , "redundant `return` statement" },
46
- {`should replace this if statement with an unconditional strings.TrimPrefix` ,
47
- "should replace this `if` statement with an unconditional `strings.TrimPrefix`" },
52
+ {
53
+ `should replace this if statement with an unconditional strings.TrimPrefix` ,
54
+ "should replace this `if` statement with an unconditional `strings.TrimPrefix`" ,
55
+ },
48
56
49
57
// staticcheck
50
58
{`this value of (\S+) is never used$` , "this value of `${1}` is never used" },
51
- {`should use time.Since instead of time.Now\(\).Sub$` ,
52
- "should use `time.Since` instead of `time.Now().Sub`" },
53
- {`should check returned error before deferring response.Close\(\)$` ,
54
- "should check returned error before deferring `response.Close()`" },
59
+ {
60
+ `should use time.Since instead of time.Now\(\).Sub$` ,
61
+ "should use `time.Since` instead of `time.Now().Sub`" ,
62
+ },
63
+ {
64
+ `should check returned error before deferring response.Close\(\)$` ,
65
+ "should check returned error before deferring `response.Close()`" ,
66
+ },
55
67
{`no value of type uint is less than 0$` , "no value of type `uint` is less than `0`" },
56
68
57
69
// unused
58
70
{`(func|const|field|type|var) (\S+) is unused$` , "${1} `${2}` is unused" },
59
71
60
72
// typecheck
61
73
{`^unknown field (\S+) in struct literal$` , "unknown field `${1}` in struct literal" },
62
- {`^invalid operation: (\S+) \(variable of type (\S+)\) has no field or method (\S+)$` ,
63
- "invalid operation: `${1}` (variable of type `${2}`) has no field or method `${3}`" },
74
+ {
75
+ `^invalid operation: (\S+) \(variable of type (\S+)\) has no field or method (\S+)$` ,
76
+ "invalid operation: `${1}` (variable of type `${2}`) has no field or method `${3}`" ,
77
+ },
64
78
{`^undeclared name: (\S+)$` , "undeclared name: `${1}`" },
65
- {`^cannot use addr \(variable of type (\S+)\) as (\S+) value in argument to (\S+)$` ,
66
- "cannot use addr (variable of type `${1}`) as `${2}` value in argument to `${3}`" },
79
+ {
80
+ `^cannot use addr \(variable of type (\S+)\) as (\S+) value in argument to (\S+)$` ,
81
+ "cannot use addr (variable of type `${1}`) as `${2}` value in argument to `${3}`" ,
82
+ },
67
83
{`^other declaration of (\S+)$` , "other declaration of `${1}`" },
68
84
{`^(\S+) redeclared in this block$` , "`${1}` redeclared in this block" },
69
85
70
86
// golint
71
- {`^exported (type|method|function|var|const) (\S+) should have comment or be unexported$` ,
72
- "exported ${1} `${2}` should have comment or be unexported" },
73
- {`^comment on exported (type|method|function|var|const) (\S+) should be of the form "(\S+) ..."$` ,
74
- "comment on exported ${1} `${2}` should be of the form `${3} ...`" },
87
+ {
88
+ `^exported (type|method|function|var|const) (\S+) should have comment or be unexported$` ,
89
+ "exported ${1} `${2}` should have comment or be unexported" ,
90
+ },
91
+ {
92
+ `^comment on exported (type|method|function|var|const) (\S+) should be of the form "(\S+) ..."$` ,
93
+ "comment on exported ${1} `${2}` should be of the form `${3} ...`" ,
94
+ },
75
95
{`^should replace (.+) with (.+)$` , "should replace `${1}` with `${2}`" },
76
- {`^if block ends with a return statement, so drop this else and outdent its block$` ,
77
- "`if` block ends with a `return` statement, so drop this `else` and outdent its block" },
78
- {`^(struct field|var|range var|const|type|(?:func|method|interface method) (?:parameter|result)) (\S+) should be (\S+)$` ,
79
- "${1} `${2}` should be `${3}`" },
80
- {`^don't use underscores in Go names; var (\S+) should be (\S+)$` ,
81
- "don't use underscores in Go names; var `${1}` should be `${2}`" },
96
+ {
97
+ `^if block ends with a return statement, so drop this else and outdent its block$` ,
98
+ "`if` block ends with a `return` statement, so drop this `else` and outdent its block" ,
99
+ },
100
+ {
101
+ `^(struct field|var|range var|const|type|(?:func|method|interface method) (?:parameter|result)) (\S+) should be (\S+)$` ,
102
+ "${1} `${2}` should be `${3}`" ,
103
+ },
104
+ {
105
+ `^don't use underscores in Go names; var (\S+) should be (\S+)$` ,
106
+ "don't use underscores in Go names; var `${1}` should be `${2}`" ,
107
+ },
82
108
}
83
109
84
110
type IdentifierMarker struct {
0 commit comments