Skip to content

Commit 307c287

Browse files
committed
Fix #388: include staticcheck check name into a message
1 parent ebadb7a commit 307c287

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

pkg/golinters/megacheck.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ func (m megacheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.I
258258
}
259259

260260
res = append(res, result.Issue{
261-
Pos: i.Position,
262-
Text: i.Text,
261+
Pos: i.Position,
262+
// TODO: use severity
263+
Text: fmt.Sprintf("%s: %s", i.Check, i.Text),
263264
FromLinter: i.Checker,
264265
})
265266
}

pkg/result/processors/identifier_marker.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,26 @@ var replacePatterns = []replacePattern{
3636
{`^TLS InsecureSkipVerify set true.$`, "TLS `InsecureSkipVerify` set true."},
3737

3838
// gosimple
39-
{`^should replace loop with (.*)$`, "should replace loop with `${1}`"},
40-
{`^should use a simple channel send/receive instead of select with a single case`,
39+
{`should replace loop with (.*)$`, "should replace loop with `${1}`"},
40+
{`should use a simple channel send/receive instead of select with a single case`,
4141
"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 (.+)$`,
42+
{`should omit comparison to bool constant, can be simplified to (.+)$`,
4343
"should omit comparison to bool constant, can be simplified to `${1}`"},
44-
{`^should write (.+) instead of (.+)$`, "should write `${1}` instead of `${2}`"},
45-
{`^redundant return statement$`, "redundant `return` statement"},
44+
{`should write (.+) instead of (.+)$`, "should write `${1}` instead of `${2}`"},
45+
{`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`"},
4648

4749
// staticcheck
48-
{`^this value of (\S+) is never used$`, "this value of `${1}` is never used"},
49-
{`^should use time.Since instead of time.Now\(\).Sub$`,
50+
{`this value of (\S+) is never used$`, "this value of `${1}` is never used"},
51+
{`should use time.Since instead of time.Now\(\).Sub$`,
5052
"should use `time.Since` instead of `time.Now().Sub`"},
51-
{`^should check returned error before deferring response.Close\(\)$`,
53+
{`should check returned error before deferring response.Close\(\)$`,
5254
"should check returned error before deferring `response.Close()`"},
53-
{`^no value of type uint is less than 0$`, "no value of type `uint` is less than `0`"},
55+
{`no value of type uint is less than 0$`, "no value of type `uint` is less than `0`"},
5456

5557
// unused
56-
{`^(func|const|field|type|var) (\S+) is unused$`, "${1} `${2}` is unused"},
58+
{`(func|const|field|type|var) (\S+) is unused$`, "${1} `${2}` is unused"},
5759

5860
// typecheck
5961
{`^unknown field (\S+) in struct literal$`, "unknown field `${1}` in struct literal"},

pkg/result/processors/identifier_marker_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func TestIdentifierMarker(t *testing.T) {
4343
"don't use underscores in Go names; var `Go_lint` should be `GoLint`"},
4444
{"G501: Blacklisted import crypto/md5: weak cryptographic primitive",
4545
"G501: Blacklisted import `crypto/md5`: weak cryptographic primitive"},
46+
{"S1017: should replace this if statement with an unconditional strings.TrimPrefix",
47+
"S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix`"},
4648
}
4749
p := NewIdentifierMarker()
4850

0 commit comments

Comments
 (0)