-
Notifications
You must be signed in to change notification settings - Fork 186
Support excluding entire directories #539
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
also needed to fix #438 for the .lintr config file based test case to succeed. |
cc @russHyde @jimhester My hacky fix to #438 isn't quite as nice as #439 (currently not merged) The approach in this PR is to temporarily setwd() in the only place where a directory prefix is necessary and set it back on.exit, namely when reading settings. #439 instead introduces a new argument to We could also merge #439 first but its diff is kind of large at a quick glance. |
Hi @AshesITR , I've been quiet on the lintr front for 6 months (job & family reasons). I never actually finished #439 ; my changeset was pretty large to begin with, and a collaborator pushed some additional changes onto my fork of lintr; so the changeset got really large. I'd like to split it into smaller chunks so that it's more easy to review, but I'm not sure where to start. I'll try to look over your changes in the coming week (haven't looked at them yet), but would urge against using |
A rebase to master caused some unexpected diffs... Thanks @russHyde for the feedback so far - I've removed the call to Edit: I've created a squashed rebase commit f29437a. fixes #438 as well as a few unrelated test failures on non-english locales (temporary calls to |
always normalize exclusions in lint_dir normalize exclusions in read_settings wrt .lintr file location fix tests with language-dependent error messages adapt tests to new settings behaviour fix cache operations forcing read_settings - this caused test failures for exclusions. Previously, the incorrect normalization of exclusions let the tests pass because the files weren't matched to their exclusion entries in .lintr but now they do and care needs to be taken not to call read_settings() which would load the exclusions from lintr/.lintr
…rate error make sure entire file exclusions properly apply to Windows as well (otherwise .lintr wouldn't be respected for the offending file on Windows)
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.
Thanks for the PR, and for requesting my review. I like how you approached excluding directories. I've requested a couple of changes.
I started a PR that aimed to address the relative-path exclusions issue in #438. I'd like to check whether the tests that were written for that PR are all adressed in this PR before continuing.
original author: @russHyde
.lintr-ignore newly added test package in the main .lintr
Thank you @russHyde for taking the time to do a review. |
# These packages should not have a .lintr file: Hardcoding a .lintr in a | ||
# dummy package throws problems during `R CMD check` (they are flagged as | ||
# hidden files, but can't be added to RBuildIgnore since they should be | ||
# available during `R CMD check` tests) |
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.
As a side note: Couldn't we override the options(lintr.linter_file = "test_dot_lintr")
to overcome R CMD check warnings about hidden files?
@russHyde do you have the time for another round of review? |
Okay. I'll look at it today |
In it's current form, with a dummy package in "tests/testthat/package", if you run the following from the
And, on
an error comes up: "Error in normalize_exclusions(c(exclusions, settings$exclusions), root = path, : object 'pattern' not found" But, when a ".lintr" file is added into the "package" root with Although the current PR does a good job of ensuring that directories are excluded when specified in the .lintr config, it doesn't appear to handle directory-exclusions that are passed via the exclusions = "..." arguments. This was an issue that meant my original PR for handling relative filepaths got really large. I am happy for this PR to be merged, provided that you explicitly say that it handles directory exclusions that are specified in the .lintr config. If you do this, can you open a new issue about supporting directory exclusions via the "exclusions" argument to the lint_*() functions. (Maybe have a look at how @joaopmatias handled it in the unmerged russHyde#2 ) |
add parse_settings to lint_package() mainly for tests (suppressing global .lintr config exclusions)
Thanks @russHyde The current behaviour in this PR would be that It's not hard to change this. What do you prefer? |
I'd really rather that that was done in a separate PR. We'd have to discuss whether files in When exclusions are specified within the .lintr it seems a lot simpler: files should be specified relative to the directory containing the .lintr file or as full-paths. |
Sounds good. Then this PR is done as far as I can tell. |
ping @russHyde travis build is finally complete |
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.
Just some minor changes. Happy to merge this without CI if these are addressed.
@russHyde thanks for taking all the time to review this thoroughly. |
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.
LGTM
Feel free to merge whenever. Many thanks for your hard work on this issue. |
fixes #518
fixes #438
The current solution is a bit inefficient since you could technically avoid listing the ignored directory.
Instead, we add full file exclusions for all files in the directories.