-
Notifications
You must be signed in to change notification settings - Fork 184
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
Feature: allow turning off specific linters per-line #605
Comments
Another usecase would be to enforce the location of # nolint start library_linter
# Place all necessary library() calls here
library(tidyverse)
# nolint end |
I agree and this feature is key to preventing code from slowly getting
worse in some gated off sections -- if we limit the gating to a specific
linter, and either the code is changed or new liners are added in the
future, it can continue to be detected.
Have had this on my back burner to bring up, but haven't thought of a good
API for it.
# nolint(...)
# lintr: off(...)
where ... are linter names?
I'm not sure that extends easily to all custom nolint tags, however.
…On Sat, Nov 28, 2020, 2:50 PM AshesITR ***@***.***> wrote:
Another usecase would be to enforce the location of library() calls in
some centralized location for larger analysis projects.
You could define library_linter =
undesirable_functions_linter(c("library" = "place all library() calls at
the top of main.R"))
and combine that with a section like
# nolint start library_linter# Place all necessary library() calls here
library(tidyverse)# nolint end
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#605 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB2BA5PER6O4S3F5V7GWQR3SSFIA5ANCNFSM4UFYZHZQ>
.
|
I think whatever the API becomes, it should be specified as some well-defined suffix of the (user-configured) Tending against parenthesis because that looks akward for block exclusions: # nolint start(library_linter, object_name_linter) |
Also note that a blanket inclusion of things after the
which is why I think we'll need some sort of glyph to signal "this is naming linters, not free text" I think it should "work" to consider all the stuff after |
What about a colon and a dot?
On the other end it's a lot easier to remember "just stick the names at the end". |
It might be useful to disable only a specific linter on a per-line basis, e.g.
produces two default lints:
object_name_linter
andassignment_linter
.One may actively decide that
%||%
is an acceptable name here and not want to generally disableobject_name_linter
.Currently, this can only be achieved by # nolint'ing the entire line
but unfortunately this also kills the
assignment_linter
It would be very useful to have a way to only exclude some linters on a line (or in a block).
A syntax might be a space-separated list of linters to be disabled, e.g.
I realize this would require work in the way exclusions are specified. Especially the line-based specification in
.lintr
files or theexclusions
argument requires thought.One solution would be one more level of (optional) nesting
The text was updated successfully, but these errors were encountered: