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
Support multiple .lintr files in nested directories? #1976
I would like to apply different linter configs to different directories.
In particular, I would turn off quotes_linter() in my tests/ directory, but use quotes_linter("'") in the rest of the package. " can be particularly good for tests where we might compare to dput() output, and dput uses ".
./ # package TLD
./.lintr # has linters: linters_with_defaults(quotes_linter('"'))
./tests/.lintr # has linters: linters_with_defaults(quotes_linter('"'))
AFAICT this doesn't work, and only the top-level config applies.
This is due to the parse_settigs = FALSE argument passed from lint_package() and lint_dir() respectively.
If we want to be smart about the config detection, we probably need to instead track the absolute path of the currently active settings and check during each call to lint() if we need to reload the settings.
If we do that, we should
upgrade our error messages related to settings so that the path to the config file is also provided
think about what to do with the argument parse_settings if a user provides it.
I'd like to run undesirable_function_linter(c(sapply = NA)) in package code (R directory), but think it's fine to use sapply() in vignettes. Currently the way to do this is:
But that's not flexible enough -- if we want to mark any other functions as undesirable, the exclusions entry will also be disabled in the vignettes directory.
The two improvements that come to mind here are:
Support some way in .lintr to mess with the parameterization of the linter that's run
Allow keeping a .lintr config in the vignettes directory
Nice idea! The only downside there is mental overload of having to remember the renamed linter. Easy for two new linters but trickier if we have dozens of undesirable functions.
At least the linter name appears in the lint message so ex post you don't have to know the linter name, but I see what you mean.
Another issue with this is if you wanted to only lint some things in a specific directory, the exclusions would get quite big.
Activity
AshesITR commentedon Jul 1, 2023
This is due to the
parse_settigs = FALSEargument passed fromlint_package()andlint_dir()respectively.If we want to be smart about the config detection, we probably need to instead track the absolute path of the currently active settings and check during each call to
lint()if we need to reload the settings.If we do that, we should
parse_settingsif a user provides it.MichaelChirico commentedon Oct 23, 2023
Another use case:
I'd like to run
undesirable_function_linter(c(sapply = NA))in package code (R directory), but think it's fine to usesapply()in vignettes. Currently the way to do this is:But that's not flexible enough -- if we want to mark any other functions as undesirable, the
exclusionsentry will also be disabled in thevignettesdirectory.The two improvements that come to mind here are:
.lintrconfig in the vignettes directoryOf those the latter seems much more promising.
AshesITR commentedon Oct 23, 2023
Regarding your use case: You can define two
undesirable_function_linter()s with separate names and exclude only one of them invignettes.MichaelChirico commentedon Oct 23, 2023
Nice idea! The only downside there is mental overload of having to remember the renamed linter. Easy for two new linters but trickier if we have dozens of undesirable functions.
AshesITR commentedon Oct 23, 2023
At least the linter name appears in the lint message so ex post you don't have to know the linter name, but I see what you mean.
Another issue with this is if you wanted to only lint some things in a specific directory, the
exclusionswould get quite big.