Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Sep 4, 2024
1 parent d01272c commit 07ded93
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/golinters/nolintlint/internal/nolintlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,17 @@ func (l Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error) {

// when detecting unused directives, we send all the directives through and filter them out in the nolint processor
if (l.needs & NeedsUnused) != 0 {
removeNolintCompletely := &result.Replacement{
Inline: &result.InlineFix{
removeNolintCompletely := &result.Replacement{}

if removeNolintCompletely.Inline.StartCol == 0 {
// if the directive starts from a new line, remove the line
removeNolintCompletely.NeedOnlyDelete = true
} else {
removeNolintCompletely.Inline = &result.InlineFix{
StartCol: pos.Column - 1,
Length: end.Column - pos.Column,
NewString: "",
},
}
// if the directive starts from a new line, remove the line
if removeNolintCompletely.Inline.StartCol == 0 {
removeNolintCompletely.NeedOnlyDelete = true
removeNolintCompletely.Inline = nil
}
}

if len(linters) == 0 {
Expand Down

0 comments on commit 07ded93

Please sign in to comment.