-
Notifications
You must be signed in to change notification settings - Fork 193
Adding function lintr_dir to check R files for given path #360
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
My team could definitely use this if it was added! |
I'm seeing similar test failures on a different branch |
This would be tremendously useful. Is there anything I can do to help to get this pull request merged into master? |
The main reason I haven't merged it is it duplicates logic that would be better off refactored into a function that could be used here and in |
@jimhester lint_package() has been refactored. |
Codecov Report
@@ Coverage Diff @@
## master #360 +/- ##
==========================================
+ Coverage 81.74% 83.03% +1.29%
==========================================
Files 46 46
Lines 1972 1975 +3
==========================================
+ Hits 1612 1640 +28
+ Misses 360 335 -25
Continue to review full report at Codecov.
|
R/lint.R
Outdated
file %in% names(exclusions) && exclusions[[file]] == Inf | ||
}, | ||
logical(1)) | ||
function(i) { |
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.
@arekbee I think this file will benefit from styling with styler package - https://github.com/r-lib/styler
this will make review easier.
…when #no_lint_end > #no_lint_start
R/lint.R
Outdated
#' Apply one or more linters to all of the R files in a package. | ||
#' @param path the path to the base directory of the package, if \code{NULL}, | ||
#' Apply one or more linters to all of the R files in a directory | ||
#' @param path the path to the base directory, if \code{NULL}, |
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.
Could you check what actually happens when NULL is passed as the base-path, from the code it looks like the function will die (because dir(NULL)
will)
function(x) { | ||
x$filename <- re_substitutes(x$filename, rex(path, one_of("/", "\\")), "") | ||
x | ||
}) | ||
attr(lints, "path") <- 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.
None of the logic in lines 162-189 has changed; IMO, although styling tools are very useful, their use only simplifies PR review when applied consistently. Here, styler has made it look like more lines have changed than really have been changed, because it had been applied to code that hadn't previously been 'styler'ed. (there's no point changing the code back to its previous state, though)
R/lint.R
Outdated
#' @param ... additional arguments passed to \code{\link{lint}}, e.g. | ||
#' \code{cache} or \code{linters}. | ||
#' @param exclusions exclusions for \code{\link{exclude}}, relative to the | ||
#' package 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.
The definitions for path
, relative_path
, ...
and exclusions
are almost identical to their definitions for lint_dir
. You could use @inheritParams lint_dir
to deduplicate the docs and rewrite the docs for lint_dir
to apply generally for both lint_dir
and lint_package
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.
hi @russHyde , thank you for the tip. I haven't used @inheritParams yet.
tests/testthat/test-exclusions.R
Outdated
@@ -198,4 +208,30 @@ test_that("it excludes properly", { | |||
} | |||
}) | |||
|
|||
test_that("it excludes properly by dir", { | |||
read_settings(NULL) |
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.
I'm afraid I don't understand what's happening in these tests. Should the user need to use read_settings()
before using lint_dir
? Could you add some comments to explain what is being setup and what is being tested when these tests run, please.
@@ -1,4 +1,14 @@ | |||
context("knitr_formats") | |||
|
|||
test_that("it handles dir", { | |||
lints <- lint_dir(path = "knitr_formats", pattern = rex::rex(".R", one_of("html", "md", "nw", "rst", "tex", "txt"))) |
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.
perhaps rex::one_of
How can I increase codecov/patch from 66.66% to 81,74% ?? |
No description provided.