Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nolint directive removal leaves whitespace behind #4384

Closed
5 tasks done
scop opened this issue Feb 14, 2024 · 1 comment
Closed
5 tasks done

nolint directive removal leaves whitespace behind #4384

scop opened this issue Feb 14, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@scop
Copy link
Contributor

scop commented Feb 14, 2024

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.).
@scop scop added the bug Something isn't working label Feb 14, 2024
@ldez ldez added question Further information is requested and removed bug Something isn't working labels Feb 14, 2024
@ldez
Copy link
Member

ldez commented Feb 14, 2024

Hello,

Due to a change of go fmt inside go1.19 (July 2022).
We have to enforce the directive style, see #3002.

The syntax of directives is: [a-zA-Z]+:[a-zA-Z].*.

//nolint should be replaced by //nolint:all.

https://golangci-lint.run/usage/false-positives/#nolint-directive

duplicate of #3554, #3101, #3109, #3098, #3069, #3068, #3063.

@ldez ldez closed this as completed Feb 14, 2024
@ldez ldez added duplicate This issue or pull request already exists and removed question Further information is requested labels Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants