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:" comment in Go is reformatted to "// nolint:" #21035

Open
1 task done
nirs opened this issue Nov 22, 2024 · 0 comments
Open
1 task done

"//nolint:" comment in Go is reformatted to "// nolint:" #21035

nirs opened this issue Nov 22, 2024 · 0 comments
Labels
admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue

Comments

@nirs
Copy link

nirs commented Nov 22, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

The golangci-lint tool use //nolint: machine readable comments to disable linter checks for line or block. This is useful to avoid false positives for specific file.

When saving, the comment is reformatted to // nolint:. This make things worse since golangci-lint does not treat this as comment, and it adds 2 extra failures for not formatting the nolint comment properly.

This may need to be fixed by golangci-lint by accepting // nolint:, but I think the formatter should be smarter about such comments since this is a very popular tool.

It seems that the formatter need to learn about //nolint: comments by default, or support anything with this pattern: ^//[\w+]:.

This is a pretty bad bug - your options are:

  • Use another editor to edit the file and fix the broken comment
  • Change the code to avoid lint issue
  • Disable the specific linter globally in the project

All options are bad.

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

Environment

Zed: v0.162.3 (Zed)
OS: macOS 15.1.1
Memory: 32 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log

@nirs nirs added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Nov 22, 2024
@nirs nirs changed the title //nolint: comment in Go is reformatted to // nolint: "//nolint:" comment in Go is reformatted to "// nolint:" Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue
Projects
None yet
Development

No branches or pull requests

1 participant