Skip to content

Commit

Permalink
chore: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Feb 3, 2023
1 parent de0b39a commit d5549a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 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
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 d5549a2

Please sign in to comment.