-
Notifications
You must be signed in to change notification settings - Fork 186
Allow turning off specific linters per line #660
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
Conversation
no parsing yet
This is going to be a fairly large changeset. That would mean the defaults work by appending cc @jimhester @russHyde |
Sorry so the syntax would be:
Seems ok, is it obvious that the specified linters are being dropped?; |
What does the syntax look like for disabling optioned linters? Mainly I have in mind something like
|
I'd actually always use the (unique) name that the user gives in @russHyde: almost. Note we added a full stop after the list, so it would be The proposed syntax could be read as |
Here are some sample codes for easier side-by-side comparison of the two suggestions: X = 42 # nolint: assignment_linter, object_name_linter. This is an explanation for the nolint
X = 42 # nolint: disable=assignment_linter,object_name_linter This is an explanation for the nolint
# nolint start: object_name_linter. This is an explanation for the nolint
MyClass <- function(x, ...) {
# blah
}
# nolint end
# nolint start: disable=object_name_linter This is an explanation for the nolint
MyClass <- function(x, ...) {
# blah
}
# nolint end |
I think we need to solve #664 for usability with cusom linter settings. @MichaelChirico |
I've added two new regexes to settings, defaulting to the The implementation part of this PR should be mostly done with the last commit. Review on the implementation is welcome. |
* use new features in exlusions-test * update test expectations * split test-exclusions.R into test-exclusions.R, test-parse_exclusions.R and test-normalize_exclusions.R
exclude_linter = rex::rex(start, any_spaces, ":", any_spaces, | ||
capture( | ||
name = "linters", | ||
zero_or_more(one_or_more(none_of(",.")), any_spaces, ",", any_spaces), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that this means downstream custom linters can't have .
in their name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have this regex lying around btw for a valid R SYMBOL
name:
[a-zA-Z][a-zA-Z0-9._]*|[.]|[.][a-zA-Z._][a-zA-Z0-9._]*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That complicates the : ... .
syntax.
I'll open up a discussion whether we should still change the default here while it's hot.
I think using (
and )
as opener and closer respectively should turn out okay, but I'd like to make this change in a new PR, correcting all our internal # nolints
for this as well.
WDYT?
@AshesITR sorry for the delay -- have been moving across the country since early December, finally getting settles with a good enough setup to do a review. Some higher-level thoughts:
|
Thanks for you review, @MichaelChirico. re 1.: crossref #690 re 2.: The default is
What might work here (accepting
re 3.: The way we currently work is we take the name of the linter from the re 4.: This would be a breaking change once we publish, since it changes the semantics of e.g.
Will throw a type |
yes that's what i had in mind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to merge at this point. @russHyde and/or @jimhester it would be good to get your high-level input as well so we have a bit more consensus on the high-level "API" for this feature before release.
Let's merge for now and discuss the high-level API w.r.t. support for scoping and out-of-the-box support for |
I have spent some 20 minutes trying to figure out why
would also suppress other linters. In my eyes, the need to have a final dot even when a comment is not following makes it way too easy to do this wrong - especially since Something like #690 is definitely required if the dot requirement is not removed. |
Fixes #605
lint()
andnormalize_exclusions()
parse_exclusions()
exclude
argument