Skip to content

Commit 07ded93

Browse files
committed
review
1 parent d01272c commit 07ded93

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/golinters/nolintlint/internal/nolintlint.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,17 @@ func (l Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error) {
252252

253253
// when detecting unused directives, we send all the directives through and filter them out in the nolint processor
254254
if (l.needs & NeedsUnused) != 0 {
255-
removeNolintCompletely := &result.Replacement{
256-
Inline: &result.InlineFix{
255+
removeNolintCompletely := &result.Replacement{}
256+
257+
if removeNolintCompletely.Inline.StartCol == 0 {
258+
// if the directive starts from a new line, remove the line
259+
removeNolintCompletely.NeedOnlyDelete = true
260+
} else {
261+
removeNolintCompletely.Inline = &result.InlineFix{
257262
StartCol: pos.Column - 1,
258263
Length: end.Column - pos.Column,
259264
NewString: "",
260-
},
261-
}
262-
// if the directive starts from a new line, remove the line
263-
if removeNolintCompletely.Inline.StartCol == 0 {
264-
removeNolintCompletely.NeedOnlyDelete = true
265-
removeNolintCompletely.Inline = nil
265+
}
266266
}
267267

268268
if len(linters) == 0 {

0 commit comments

Comments
 (0)