Skip to content

Commit

Permalink
staticcheck: bump to v0.4.0 (#3551)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Feb 3, 2023
1 parent 06e3515 commit 7beb2fb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ issues:
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead."
- path: pkg/lint/lintersdb/manager.go
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."
- path: pkg/golinters/unused.go
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"

run:
timeout: 5m
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ require (
gitlab.com/bosi/decorder v0.2.3
golang.org/x/tools v0.5.0
gopkg.in/yaml.v3 v3.0.1
honnef.co/go/tools v0.4.0-0.dev.0.20221209223220-58c4d7e4b720
honnef.co/go/tools v0.4.0
mvdan.cc/gofumpt v0.4.0
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions pkg/golinters/unused.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,19 @@ func runUnused(pass *analysis.Pass) ([]goanalysis.Issue, error) {
return nil, err
}

sr := unused.Serialize(pass, res.(unused.Result), pass.Fset)

used := make(map[string]bool)
for _, obj := range sr.Used {
for _, obj := range res.(unused.Result).Used {
used[fmt.Sprintf("%s %d %s", obj.Position.Filename, obj.Position.Line, obj.Name)] = true
}

var issues []goanalysis.Issue

// Inspired by https://github.com/dominikh/go-tools/blob/d694aadcb1f50c2d8ac0a1dd06217ebb9f654764/lintcmd/lint.go#L177-L197
for _, object := range sr.Unused {
for _, object := range res.(unused.Result).Unused {
if object.Kind == "type param" {
continue
}

if object.InGenerated {
continue
}

key := fmt.Sprintf("%s %d %s", object.Position.Filename, object.Position.Line, object.Name)
if used[key] {
continue
Expand Down

0 comments on commit 7beb2fb

Please sign in to comment.