Fix #388: include staticcheck check name into a message
This commit is contained in:
parent
ebadb7a679
commit
307c287356
@ -259,7 +259,8 @@ func (m megacheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.I
|
|||||||
|
|
||||||
res = append(res, result.Issue{
|
res = append(res, result.Issue{
|
||||||
Pos: i.Position,
|
Pos: i.Position,
|
||||||
Text: i.Text,
|
// TODO: use severity
|
||||||
|
Text: fmt.Sprintf("%s: %s", i.Check, i.Text),
|
||||||
FromLinter: i.Checker,
|
FromLinter: i.Checker,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -36,24 +36,26 @@ var replacePatterns = []replacePattern{
|
|||||||
{`^TLS InsecureSkipVerify set true.$`, "TLS `InsecureSkipVerify` set true."},
|
{`^TLS InsecureSkipVerify set true.$`, "TLS `InsecureSkipVerify` set true."},
|
||||||
|
|
||||||
// gosimple
|
// gosimple
|
||||||
{`^should replace loop with (.*)$`, "should replace loop with `${1}`"},
|
{`should replace loop with (.*)$`, "should replace loop with `${1}`"},
|
||||||
{`^should use a simple channel send/receive instead of select with a single case`,
|
{`should use a simple channel send/receive instead of select with a single case`,
|
||||||
"should use a simple channel send/receive instead of `select` with a single case"},
|
"should use a simple channel send/receive instead of `select` with a single case"},
|
||||||
{`^should omit comparison to bool constant, can be simplified to (.+)$`,
|
{`should omit comparison to bool constant, can be simplified to (.+)$`,
|
||||||
"should omit comparison to bool constant, can be simplified to `${1}`"},
|
"should omit comparison to bool constant, can be simplified to `${1}`"},
|
||||||
{`^should write (.+) instead of (.+)$`, "should write `${1}` instead of `${2}`"},
|
{`should write (.+) instead of (.+)$`, "should write `${1}` instead of `${2}`"},
|
||||||
{`^redundant return statement$`, "redundant `return` statement"},
|
{`redundant return statement$`, "redundant `return` statement"},
|
||||||
|
{`should replace this if statement with an unconditional strings.TrimPrefix`,
|
||||||
|
"should replace this `if` statement with an unconditional `strings.TrimPrefix`"},
|
||||||
|
|
||||||
// staticcheck
|
// staticcheck
|
||||||
{`^this value of (\S+) is never used$`, "this value of `${1}` is never used"},
|
{`this value of (\S+) is never used$`, "this value of `${1}` is never used"},
|
||||||
{`^should use time.Since instead of time.Now\(\).Sub$`,
|
{`should use time.Since instead of time.Now\(\).Sub$`,
|
||||||
"should use `time.Since` instead of `time.Now().Sub`"},
|
"should use `time.Since` instead of `time.Now().Sub`"},
|
||||||
{`^should check returned error before deferring response.Close\(\)$`,
|
{`should check returned error before deferring response.Close\(\)$`,
|
||||||
"should check returned error before deferring `response.Close()`"},
|
"should check returned error before deferring `response.Close()`"},
|
||||||
{`^no value of type uint is less than 0$`, "no value of type `uint` is less than `0`"},
|
{`no value of type uint is less than 0$`, "no value of type `uint` is less than `0`"},
|
||||||
|
|
||||||
// unused
|
// unused
|
||||||
{`^(func|const|field|type|var) (\S+) is unused$`, "${1} `${2}` is unused"},
|
{`(func|const|field|type|var) (\S+) is unused$`, "${1} `${2}` is unused"},
|
||||||
|
|
||||||
// typecheck
|
// typecheck
|
||||||
{`^unknown field (\S+) in struct literal$`, "unknown field `${1}` in struct literal"},
|
{`^unknown field (\S+) in struct literal$`, "unknown field `${1}` in struct literal"},
|
||||||
|
@ -43,6 +43,8 @@ func TestIdentifierMarker(t *testing.T) {
|
|||||||
"don't use underscores in Go names; var `Go_lint` should be `GoLint`"},
|
"don't use underscores in Go names; var `Go_lint` should be `GoLint`"},
|
||||||
{"G501: Blacklisted import crypto/md5: weak cryptographic primitive",
|
{"G501: Blacklisted import crypto/md5: weak cryptographic primitive",
|
||||||
"G501: Blacklisted import `crypto/md5`: weak cryptographic primitive"},
|
"G501: Blacklisted import `crypto/md5`: weak cryptographic primitive"},
|
||||||
|
{"S1017: should replace this if statement with an unconditional strings.TrimPrefix",
|
||||||
|
"S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix`"},
|
||||||
}
|
}
|
||||||
p := NewIdentifierMarker()
|
p := NewIdentifierMarker()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user