File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,27 @@ func NewUnused(settings *config.StaticCheckSettings) *goanalysis.Linter {
35
35
36
36
sr := unused .Serialize (pass , res .(unused.Result ), pass .Fset )
37
37
38
+ used := make (map [string ]bool )
39
+ for _ , obj := range sr .Used {
40
+ used [fmt .Sprintf ("%s %d %s" , obj .Position .Filename , obj .Position .Line , obj .Name )] = true
41
+ }
42
+
38
43
var issues []goanalysis.Issue
44
+ // Inspired by https://github.com/dominikh/go-tools/blob/d694aadcb1f50c2d8ac0a1dd06217ebb9f654764/lintcmd/lint.go#L177-L197
39
45
for _ , object := range sr .Unused {
46
+ if object .Kind == "type param" {
47
+ continue
48
+ }
49
+
50
+ if object .InGenerated {
51
+ continue
52
+ }
53
+
54
+ key := fmt .Sprintf ("%s %d %s" , object .Position .Filename , object .Position .Line , object .Name )
55
+ if used [key ] {
56
+ continue
57
+ }
58
+
40
59
issue := goanalysis .NewIssue (& result.Issue {
41
60
FromLinter : name ,
42
61
Text : fmt .Sprintf ("%s %s is unused" , object .Kind , object .Name ),
You can’t perform that action at this time.
0 commit comments