-
Notifications
You must be signed in to change notification settings - Fork 186
Check for .lintr file in extra subdirectory #1757
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
If we consider this, we might also want #460 |
I can see there is a lint error raised for the cyclomatic complexity linter. I'm not sure what would be the best way to resolve. I don't see an obvious way to make the code simpler. I could increase the threshold to be 16 but not sure if that is an advised route. Hence marking as ready for review |
While the current search order is non-breaking, it seems very counter-intuitive to give a "global" config at |
Regarding the cyclomatic complexity: You could refactor the existence check into a |
Codecov Report
@@ Coverage Diff @@
## main #1757 +/- ##
==========================================
- Coverage 98.95% 98.49% -0.46%
==========================================
Files 113 113
Lines 4953 4990 +37
==========================================
+ Hits 4901 4915 +14
- Misses 52 75 +23
|
@AshesITR Thanks for the pointers, I have updated the code, it looks to be passing that and other tests now. Let me know if you suggest other changes |
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.
@tonyk7440 thanks for your work so far!
@jimhester, @MichaelChirico, @IndrajeetPatil: WDYT about expanding the config search paths?
Sounds good to me |
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.
Nice work so far, thanks!
Now that we are sure we'll accept this change, please add a test package where the .github/linters/.lintr
config takes effect.
Let me know if you need hints on how to do that.
Thanks for trying to cook up a test. Finally, to test that the config is pulled from Right now, IINM, the |
Thanks @AshesITR! I've updated the code, seems like the tests are passing now, let me know if I should make further changes. |
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.
Excellent work so far, thank you!
Just a few more adjustments.
Regarding the NEWS
wording, I'd like to have input from @MichaelChirico.
Hi @AshesITR , sorry for the delay, currently very busy with work, will try to get some time this coming weekend |
No worries, thanks for your feedback and good work so far. |
@tonyk7440 Hi, just wondering: are there any updates on this PR? |
Gentle ping @tonyk7440 as we're moving towards release and it would be ideal to include this breaking change alongside a few others at the bump to 3.1.0. If you're currently short on time, please ping & we can try and crowdsource getting this across the finish line. Thanks again! |
Hi @AshesITR @MichaelChirico @klmr , sorry for the delay in responding. |
R/settings_utils.R
Outdated
|
||
# Search through locations, return first valid result | ||
for (loc in file_locations) { | ||
if (isTRUE(file.exists(loc))) { |
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.
Why the isTRUE()
call? As far as I can tell file.exists()
should always return exactly one logical value here so this code doesn’t need to guard against non-logical values or vectors of length > 1.
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.
Ugh, this comment (along with others that seem to be gone?!) was written months ago but was somehow part of a pending review without my noticing.
Previously the test case never failed, even without the relevant patch.
This test will currently fail, and should no longer fail once `.github/linters` is searched in parent directories as well as in the current directory.
Alright, I’ve pushed my suggested changes. Happy for a review. |
vignettes/lintr.Rmd
Outdated
3. A linter file in a parent directory of the currently-searched directory, starting from the deepest path, moving upwards one level at a time. | ||
4. A linter file in the user's `HOME` directory. | ||
3. A linter file in the `.github/linters` child directory of the currently-searched directory. | ||
4. A linter file in a parent directory of the currently-searched directory, starting from the deepest path, moving upwards one level at a time. |
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.
This could be made more clear, stating that 2. and 3. are searched from the parent.
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.
Aren't we checking 2. and 3. for the current directory and only if none match, the parent is searched recursively?
This description suggests we first search for .lintr
in any parent and only look for .github/linters/.lintr
if there is no .lintr
anywhere in the path.
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.
@klmr this is the only blocker I see. Good to merge once the docs match the behavior.
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.
Oh I completely missed these comments. I agree, my description is incorrect. Will change.
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.
Updated. Please take a look. I think we won’t get around making nested bullet points, since that reflects how the algorithm works. Is this clear enough?
NEWS.md
Outdated
@@ -2,6 +2,7 @@ | |||
|
|||
## Deprecations & Breaking Changes | |||
|
|||
* .lintr configs can now be kept in the directory .github/linters for better compatibility with Super-Linter. Note that this may be a breaking change if you already have a config in both such a directory and in your R project's root since the former will now be discovered first where it was ignored before. Please see vignette("lintr") for details on how configs are discovered. (#1746, @tonyk7440) |
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.
IINM, the only breaking constellation is if .github/linter/.lintr
is in a subdirectory, right?
i.e.
.lintr
tests/.github/linters/.lintr
will find a different config when run from tests/
. Is that correct?
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.
Also, you should add your name, @klmr.
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.
You’re absolutely right! Will amend.
Fixed the description based on review, performed very minor copy editing, and adapted formatting to be consistent.
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. Just a minor nitpick left.
vignettes/lintr.Rmd
Outdated
2. A project-local linter file; that is, either | ||
1. a linter file (that is, a file named like `lintr.linter_file`) in the currently-searched directory, i.e. the directory of the file passed to `lint()`; or | ||
2. a linter file in the `.github/linters` child directory of the currently-searched directory. | ||
3. A project-local linter file in the closest parent directory of the currently-searched directory, starting from the deepest path, moving upwards one level at a time. When run from `lint_package()`, this directory can differ for each linted file. |
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.
nit: Whitespace is inconsistent across top-level bullets.
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.
Oops. Fixed.
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 a lot, you two!
@AshesITR it looked like this is ready to merge, LMK if that was in error. |
Fixes #1746
Added another condition to check for the
.lintr
file in the.github/linters
subdirectory to improve compatibility with Super-Linter.Let me know if there's anything I missed, happy to update