Skip to content

nolint directive removal leaves whitespace behind #4384

Closed
@scop

Description

@scop

Welcome

Description of the problem

When a //nolint directive is being removed as part of an automatic fix, undesirable whitespace -- empty lines, or trailing whitespace -- gets left behind.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.56.1 built with go1.22.0 from a25592b5 on 2024-02-08T18:03:33Z

Configuration

--enable=nolintlint --fix

Go environment

$ go version && go env
# paste output here

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

A minimal reproducible example or link to a public repository

package main

import "fmt"

//nolint
func main() {
	fmt.Println("Hello, world!") //nolint
}

The fix leaves an empty line behind where the top level //nolint was on line 5, and a trailing whitespace after ) where the inline //nolint was on line 7. Both the empty line and the trailing whitespace should be removed.

Validation

  • Yes, I've included all information above (version, config, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions