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

Disabling a rule for a block without reenable #885

Open
yonderblue opened this issue Aug 29, 2023 · 5 comments
Open

Disabling a rule for a block without reenable #885

yonderblue opened this issue Aug 29, 2023 · 5 comments
Labels

Comments

@yonderblue
Copy link

There is the //revive:disable:blah and then //revive:enable:blah but being able to put the disable on a block like a func similar to how nolint is supported would be peachy.

@chavacava
Copy link
Collaborator

Hi @yonderblue thanks for the proposal.
My understanding of your proposal is: scoped disabling directives.
Current implementation uses position (line numbers) of directives without scoping information. I'm afraid, making directive scoped will require almost complete reworking of the implementation. Backward compatibility makes things harder (if not impossible)
To resume, IMO the funtional gain does not worth the work and complexity grow.
I'll let this usue open to discussion.

@yonderblue
Copy link
Author

That is understandable. How about then splitting out into individual linters so that golangci-lint's existing scope and features could be used for each?

@chavacava
Copy link
Collaborator

I'm not sure I understand the "splitting out into individual linters" idea. Anyway, if you are using revive through golangci-lint you can fully delegate the disabling/enabling of rules to golangci-lint (in other words, use //nolint:blah instead of //revive:disable:blah

@yonderblue
Copy link
Author

in other words, use //nolint:blah instead of //revive:disable:blah

Sorry I must have missed that support, or am trying it wrong? golangci-lint gives me for example:

apkg/afile.go:125:3: unhandled-error: Unhandled error in call to function e.Run (revive)
		e.Run(ctx) //nolint:unhandled-error

but using //revive:disable-line:unhandled-error in that same spot works.

@chavacava
Copy link
Collaborator

Well I'm not a golangci-lint user.
My understanding is that golangci-lint implements its own mechanism for enabling/disabling rules independent of that from underlying linters.
You might ask on the golangci-lint project on how to achieve scoped disabling (or why the annotation you tested is not working at expected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants