Skip to content

Commit 3a8d495

Browse files
Lint files in exec folder on lint_package (#1950)
* Lint files in `exec` folder on lint_package FIX #1947 As per https://cran.r-project.org/doc/manuals/R-exts.html#Package-subdirectories: Subdirectory exec could contain additional executable scripts the package needs, typically scripts for interpreters such as the shell, Perl, or Tcl. * Add Oxford comma Co-authored-by: Indrajeet Patil <patilindrajeet.science@gmail.com> * Update .Rd * Test for files in exec/ * Update NEWS [skip ci] * Change file extensions .r -> .R * Update file extension Co-authored-by: Indrajeet Patil <patilindrajeet.science@gmail.com> * Update NEWS.md Co-authored-by: Indrajeet Patil <patilindrajeet.science@gmail.com> --------- Co-authored-by: Indrajeet Patil <patilindrajeet.science@gmail.com>
1 parent 2d8a12d commit 3a8d495

File tree

6 files changed

+16
-5
lines changed

6 files changed

+16
-5
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
+ `unnecessary_concatenation_linter()`
7171
+ `whitespace_linter()`
7272

73+
* `lint_package()` also looks for files in `exec/` (#1950, @jmaspons).
74+
7375
## New and improved features
7476

7577
* New `get_r_string()` helper to get the R-equivalent value of a string, especially useful for R-4-style raw strings.
@@ -184,6 +186,7 @@
184186
Thanks to Yihui and other developers for their helpful discussions around this issue (#797, @IndrajeetPatil).
185187

186188
* The output of `lint()` and `Lint()` gain S3 class `"list"` to assist with S3 dispatch (#1494, @MichaelChirico)
189+
187190
# lintr 3.0.2
188191

189192
* Fix test to avoid leaving behind cache files in the global cache directory.

R/lint.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' * `lint()` lints a single file.
44
#' * `lint_dir()` lints all files in a directory.
55
#' * `lint_package()` lints all likely locations for R files in a package, i.e.
6-
#' `R/`, `tests/`, `inst/`, `vignettes/`, `data-raw/`, and `demo/`.
6+
#' `R/`, `tests/`, `inst/`, `vignettes/`, `data-raw/`, `demo/`, and `exec/`.
77
#'
88
#' Read `vignette("lintr")` to learn how to configure which linters are run
99
#' by default.
@@ -262,7 +262,7 @@ lint_package <- function(path = ".", ...,
262262
root = pkg_path
263263
)
264264

265-
r_directories <- file.path(pkg_path, c("R", "tests", "inst", "vignettes", "data-raw", "demo"))
265+
r_directories <- file.path(pkg_path, c("R", "tests", "inst", "vignettes", "data-raw", "demo", "exec"))
266266
# TODO: once relative_path= is fully deprecated as 2nd positional argument (see top of body), restore the cleaner:
267267
# > lints <- lint_dir(r_directories, relative_path = FALSE, exclusions = exclusions, parse_settings = FALSE, ...)
268268
lints <- do.call(

man/lint.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# lint errors should be included in test-lint_package.R
2+
x = 1:4
3+
res<- lapply(x, function(y) y+1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Each of the default linters should throw at least one lint for assignment_linter or object_name_linter on this file
2+
x = 1:4
3+
res <- lapply(x, function(y) y + 1)

tests/testthat/test-lint_package.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ test_that(
2525
"abc = 123",
2626
# from jkl.R
2727
"jkl = 456",
28-
"mno = 789"
28+
"mno = 789",
29+
# from exec/script.R
30+
"x = 1:4"
2931
)
3032

3133
lints_from_outside <- lint_package(
@@ -80,7 +82,7 @@ test_that(
8082
# `jkl.R` (and remove it on finishing this test)
8183
local_config(pkg_path, "exclusions: list('R/abc.R', 'R/jkl.R' = 1)")
8284

83-
expected_lines <- "mno = 789"
85+
expected_lines <- c("mno = 789", "x = 1:4")
8486
lints_from_outside <- lint_package(
8587
pkg_path,
8688
linters = list(assignment_linter())

0 commit comments

Comments
 (0)