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 6910df4
Showing 1 changed file with 2 additions and 8 deletions.
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 6910df4

Please sign in to comment.