Closed
Description
Welcome
- Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've read the typecheck section of the FAQ (https://golangci-lint.run/usage/faq/#why-do-you-have-typecheck-errors).
- Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)
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.).