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

nolintlint: too many whitespaces removed after autofix #1580

Closed
ldez opened this issue Dec 27, 2020 · 2 comments · Fixed by #1583
Closed

nolintlint: too many whitespaces removed after autofix #1580

ldez opened this issue Dec 27, 2020 · 2 comments · Fixed by #1583
Assignees
Labels
bug Something isn't working

Comments

@ldez
Copy link
Member

ldez commented Dec 27, 2020

Related to #1573

The fix removes all whitespaces, the choice to remove all the whitespaces, in this case, seems not right.


before the fix:

// wantedErrors parses expected errors from comments in a file.
// nolint:nakedret
func wantedErrors(file, short string) (errs []wantedError) {

after the fix:

// wantedErrors parses expected errors from comments in a file.
// nolint:nakedret
func wantedErrors(file, short string) (errs []wantedError) {

OK


before the fix:

// wantedErrors parses expected errors from comments in a file.
//    nolint:nakedret
func wantedErrors(file, short string) (errs []wantedError) {

after the fix:

// wantedErrors parses expected errors from comments in a file.
//nolint:nakedret
func wantedErrors(file, short string) (errs []wantedError) {

KO

@ldez ldez added the bug Something isn't working label Dec 27, 2020
@ashanbrown
Copy link
Contributor

I'm not completely sure it is possible to determine the user's intent in this case. We don't know whether the expected coding style is to use machine-readable directives or not (unless allow-leading-whitespace is explicitly disabled in the config for nolintlint). One option might be to have nolintlint simply not try to fix this case unless allow-leading-whitespace is disabled and simply defer to the user on how to fix it. Does that sound reasonable?

@ldez
Copy link
Member Author

ldez commented Dec 27, 2020

I think that something like that can be possible:

allow-leading-whitespace:

  • true: just keep only one whitespace
  • false: drop the whitespaces

ashanbrown added a commit to ashanbrown/golangci-lint that referenced this issue Dec 27, 2020
… required

It isn't possible to determine what the whitespace convention is otherwise.

Fixes golangci#1580.
ashanbrown added a commit to ashanbrown/golangci-lint that referenced this issue Dec 27, 2020
… required

It isn't possible to determine what the whitespace convention is otherwise.

Fixes golangci#1580.
ashanbrown added a commit that referenced this issue Dec 27, 2020
…nolint statements (#1573)" (#1584)

This reverts commit aeb9830.

There are some cases that nolinter fixer wasn't handling properly or expectedly (#1579, #1580, #1581) so we'll fix those in a new attempt.
ashanbrown added a commit to ashanbrown/golangci-lint that referenced this issue Dec 27, 2020
… required

It isn't possible to determine what the whitespace convention is otherwise.

Fixes golangci#1580.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants