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

Support comments when enabling/disabling #73

Closed
chavacava opened this issue Sep 23, 2018 · 3 comments
Closed

Support comments when enabling/disabling #73

chavacava opened this issue Sep 23, 2018 · 3 comments

Comments

@chavacava
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Currently, we can enable/disable revive with comments like

//revive:disable
//revive:disable-next-line:exported,random

But the enabling/disabling comment pattern does not allow to add a, sometimes useful, explanation of why the developer is enabling/disabling the linter.

Describe the solution you'd like

It could be nice if we can write enabling/disabling directives like

//revive:disable:cyclomatic - for the moment we accept this complex function
//revive:disable:deep-exit  as discussed with Thom, in this case, it is not bad to exit from here 
@mgechev
Copy link
Owner

mgechev commented Sep 23, 2018

A comment above seems sufficient to me:

// False negative
//revive:disable

@chavacava
Copy link
Collaborator Author

A comment above seems sufficient to me:

That was my first impression when my colleagues ask for this feature.

One "problem" with a comment above the directive is that both are somewhat decoupled, thus it is possible, for example, to delete one without deleting the other.
Moreover, if the directive has the line modifier, putting a comment in the precedent line does not facilitate code reading.

func (p *exporter) marker(m byte) {
	p.rawByte(m)
	// Enable this for help tracking down the location
	// of an incorrect marker when running in debugFormat.
        // False positive
	if false && trace { // revive:disable-line:bool-literal-in-expr 
		p.tracef("#%d ", p.written)
	}
	p.rawInt64(int64(p.written))
}

@chavacava
Copy link
Collaborator Author

Closing. Requested feature will not be implemented.

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

No branches or pull requests

2 participants