You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: allow turning off specific linters per-line #605
It might be useful to disable only a specific linter on a per-line basis, e.g.
`%||%`=function(x, y) {
if (is.null(x)) yelsex
}
produces two default lints: object_name_linter and assignment_linter.
One may actively decide that %||% is an acceptable name here and not want to generally disable object_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 the exclusions argument requires thought.
One solution would be one more level of (optional) nesting
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
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>
.
Also note that a blanket inclusion of things after the # nolint tag is likely not to work (or at least to be awkward), as it's not uncommon to write some notes there about why that line's nolinted (I know I do this for covr especially), e.g.
someReallyLongLineActuallyLongerThan120Chars # nolint this object is defined elsewhere, no choice but to use here
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 nolint as linter names (maybe comma-separated) as it's unlikely to turn up matches in named lilnters, but still feels awkward.
# nolint: library_linter, object_name_linter. This is free text and will not be interpreted
# nolint start: library_linter. This ...
On the other end it's a lot easier to remember "just stick the names at the end".
We'd need to be smart about making it a general # nolint if none of the tokens following match any of the named linters.
Activity
AshesITR commentedon Nov 28, 2020
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
MichaelChirico commentedon Nov 28, 2020
AshesITR commentedon Nov 28, 2020
I think whatever the API becomes, it should be specified as some well-defined suffix of the (user-configured)
# nolintand# nolint starttags.Tending against parenthesis because that looks akward for block exclusions:
# nolint start(library_linter, object_name_linter)MichaelChirico commentedon Nov 28, 2020
Also note that a blanket inclusion of things after the
# nolinttag is likely not to work (or at least to be awkward), as it's not uncommon to write some notes there about why that line's nolinted (I know I do this forcovrespecially), e.g.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
nolintas linter names (maybe comma-separated) as it's unlikely to turn up matches in named lilnters, but still feels awkward.AshesITR commentedon Nov 28, 2020
What about a colon and a dot?
# nolint: library_linter, object_name_linter. This is free text and will not be interpreted# nolint start: library_linter. This ...On the other end it's a lot easier to remember "just stick the names at the end".
We'd need to be smart about making it a general
# nolintif none of the tokens following match any of the named linters.