Skip to content

Commit 67dc00f

Browse files
committed
review
1 parent 035450e commit 67dc00f

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24
1414
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0
1515
github.com/OpenPeeDeeP/depguard/v2 v2.1.0
16+
github.com/alecthomas/go-check-sumtype v0.1.3
1617
github.com/alexkohler/nakedret/v2 v2.0.1
1718
github.com/alexkohler/prealloc v1.0.0
1819
github.com/alingse/asasalint v0.0.11
@@ -127,7 +128,6 @@ require (
127128

128129
require (
129130
github.com/Masterminds/semver v1.5.0 // indirect
130-
github.com/alecthomas/go-check-sumtype v0.1.3
131131
github.com/beorn7/perks v1.0.1 // indirect
132132
github.com/cespare/xxhash/v2 v2.1.2 // indirect
133133
github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 // indirect

pkg/golinters/gochecksumtype.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ func NewGoCheckSumType() *goanalysis.Linter {
2727
if err != nil {
2828
return nil, err
2929
}
30+
3031
if len(issues) == 0 {
3132
return nil, nil
3233
}
34+
3335
mu.Lock()
3436
resIssues = append(resIssues, issues...)
3537
mu.Unlock()
38+
3639
return nil, nil
3740
},
3841
}
42+
3943
return goanalysis.NewLinter(
4044
goCheckSumTypeName,
4145
`Run exhaustiveness checks on Go "sum types"`,
@@ -47,13 +51,15 @@ func NewGoCheckSumType() *goanalysis.Linter {
4751
}
4852

4953
func runGoCheckSumType(pass *analysis.Pass) ([]goanalysis.Issue, error) {
50-
resIssues := []goanalysis.Issue{}
54+
var resIssues []goanalysis.Issue
55+
5156
pkg := &packages.Package{
5257
Fset: pass.Fset,
5358
Syntax: pass.Files,
5459
Types: pass.Pkg,
5560
TypesInfo: pass.TypesInfo,
5661
}
62+
5763
var unknownError error
5864
errors := gochecksumtype.Run([]*packages.Package{pkg})
5965
for _, err := range errors {
@@ -62,12 +68,13 @@ func runGoCheckSumType(pass *analysis.Pass) ([]goanalysis.Issue, error) {
6268
unknownError = err
6369
continue
6470
}
65-
prefix := err.Pos().String() + ": "
71+
6672
resIssues = append(resIssues, goanalysis.NewIssue(&result.Issue{
6773
FromLinter: goCheckSumTypeName,
68-
Text: strings.TrimPrefix(err.Error(), prefix),
74+
Text: strings.TrimPrefix(err.Error(), err.Pos().String()+": "),
6975
Pos: err.Pos(),
7076
}, pass))
7177
}
78+
7279
return resIssues, unknownError
7380
}

pkg/golinters/unparam.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewUnparam(settings *config.UnparamSettings) *goanalysis.Linter {
3737
mu.Lock()
3838
resIssues = append(resIssues, issues...)
3939
mu.Unlock()
40+
4041
return nil, nil
4142
},
4243
}

pkg/lint/lintersdb/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,9 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
471471
WithPresets(linter.PresetStyle),
472472

473473
linter.NewConfig(golinters.NewGoCheckSumType()).
474-
WithSince("v1.51.2").
474+
WithSince("v1.53.0").
475475
WithPresets(linter.PresetBugs).
476+
WithLoadForGoAnalysis().
476477
WithURL("https://github.com/alecthomas/go-check-sumtype"),
477478

478479
linter.NewConfig(golinters.NewGocognit(gocognitCfg)).

0 commit comments

Comments
 (0)