Skip to content

Commit 66c31e6

Browse files
committed
chore: simplify godot
1 parent 3c47cda commit 66c31e6

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pkg/golinters/godot/godot.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package godot
22

33
import (
44
"cmp"
5-
"go/token"
65

76
"github.com/tetafro/godot"
87
"golang.org/x/tools/go/analysis"
@@ -60,26 +59,23 @@ func runGodot(pass *analysis.Pass, settings godot.Settings) error {
6059
return err
6160
}
6261

63-
for _, i := range iss {
64-
f := pass.Fset.File(file.Pos())
62+
if len(iss) == 0 {
63+
continue
64+
}
6565

66-
pos := f.Pos(i.Pos.Offset)
66+
f := pass.Fset.File(file.Pos())
6767

68-
var end token.Pos
69-
if i.Pos.Line == f.LineCount() {
70-
// missing newline at the end of the file
71-
end = f.Pos(f.Size())
72-
} else {
73-
end = f.LineStart(i.Pos.Line+1) - token.Pos(1)
74-
}
68+
for _, i := range iss {
69+
start := f.Pos(i.Pos.Offset)
70+
end := goanalysis.EndOfLinePos(f, i.Pos.Line)
7571

7672
pass.Report(analysis.Diagnostic{
77-
Pos: pos,
73+
Pos: start,
7874
End: end,
7975
Message: i.Message,
8076
SuggestedFixes: []analysis.SuggestedFix{{
8177
TextEdits: []analysis.TextEdit{{
82-
Pos: pos,
78+
Pos: start,
8379
End: end,
8480
NewText: []byte(i.Replacement),
8581
}},

0 commit comments

Comments
 (0)