diff --git a/pkg/golinters/megacheck.go b/pkg/golinters/megacheck.go index 04d0bfd8..86425341 100644 --- a/pkg/golinters/megacheck.go +++ b/pkg/golinters/megacheck.go @@ -258,8 +258,9 @@ func (m megacheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.I } res = append(res, result.Issue{ - Pos: i.Position, - Text: i.Text, + Pos: i.Position, + // TODO: use severity + Text: fmt.Sprintf("%s: %s", i.Check, i.Text), FromLinter: i.Checker, }) } diff --git a/pkg/result/processors/identifier_marker.go b/pkg/result/processors/identifier_marker.go index a7d48f41..2d1fb580 100644 --- a/pkg/result/processors/identifier_marker.go +++ b/pkg/result/processors/identifier_marker.go @@ -36,24 +36,26 @@ var replacePatterns = []replacePattern{ {`^TLS InsecureSkipVerify set true.$`, "TLS `InsecureSkipVerify` set true."}, // gosimple - {`^should replace loop with (.*)$`, "should replace loop with `${1}`"}, - {`^should use a simple channel send/receive instead of select with a single case`, + {`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 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 write (.+) instead of (.+)$`, "should write `${1}` instead of `${2}`"}, - {`^redundant return statement$`, "redundant `return` statement"}, + {`should write (.+) instead of (.+)$`, "should write `${1}` instead of `${2}`"}, + {`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 - {`^this value of (\S+) is never used$`, "this value of `${1}` is never used"}, - {`^should use time.Since instead of time.Now\(\).Sub$`, + {`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 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 - {`^(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 {`^unknown field (\S+) in struct literal$`, "unknown field `${1}` in struct literal"}, diff --git a/pkg/result/processors/identifier_marker_test.go b/pkg/result/processors/identifier_marker_test.go index c58987c3..3cda587d 100644 --- a/pkg/result/processors/identifier_marker_test.go +++ b/pkg/result/processors/identifier_marker_test.go @@ -43,6 +43,8 @@ func TestIdentifierMarker(t *testing.T) { "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"}, + {"S1017: should replace this if statement with an unconditional strings.TrimPrefix", + "S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix`"}, } p := NewIdentifierMarker()