Repository navigation
Check for .lintr file in extra subdirectory - #1757
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 |
AshesITR
left a comment
There was a problem hiding this comment.
@tonyk7440 thanks for your work so far!
@jimhester, @MichaelChirico, @IndrajeetPatil: WDYT about expanding the config search paths?
|
Sounds good to me |
|
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.
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. |
|
|
||
| # Search through locations, return first valid result | ||
| for (loc in file_locations) { | ||
| if (isTRUE(file.exists(loc))) { |
There was a problem hiding this comment.
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.
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. |
| 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.
This could be made more clear, stating that 2. and 3. are searched from the parent.
There was a problem hiding this comment.
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.
@klmr this is the only blocker I see. Good to merge once the docs match the behavior.
There was a problem hiding this comment.
Oh I completely missed these comments. I agree, my description is incorrect. Will change.
There was a problem hiding this comment.
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?
|
|
||
| ## 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.
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.
You’re absolutely right! Will amend.
Fixed the description based on review, performed very minor copy editing, and adapted formatting to be consistent.
AshesITR
left a comment
There was a problem hiding this comment.
LGTM. Just a minor nitpick left.
| 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.
nit: Whitespace is inconsistent across top-level bullets.
AshesITR
left a comment
There was a problem hiding this comment.
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
.lintrfile in the.github/linterssubdirectory to improve compatibility with Super-Linter.Let me know if there's anything I missed, happy to update