diff --git a/NEWS.md b/NEWS.md index 9264352..8ecf103 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ I tried looking around GitHub for existing users, but if this affects you, please don't hesitate to file a FR and I can restore anything deleted too hastily. + * `stale_package_check()` is also deprecated. Prefer using `lintr::unused_import_linter()` instead. {lintr} will have better maintenance, reliability, and correctness. + * `get_age()` got some substantial improvements. + Gives the right age in some cases, e.g. 7 1/366 years for someone born Dec. 22, 2024 as of Dec. 23, 2031 (#23). Accuracy is now confirmed for a full grid of >2 million possible birthday, age combinations. + Implementation is improved for about 2x speed-up. This was in service of making the implementation friendlier for static translation to other execution engines (in particular {arrow}, #18). Thanks @TPDeramus for the request and @jonkeane for consulting on acero particulars. diff --git a/R/utils.R b/R/utils.R index 20cdb21..6b51afb 100644 --- a/R/utils.R +++ b/R/utils.R @@ -37,6 +37,7 @@ get_all_plain_calls = function(e) { # packages loaded are actually used #' @param con A connection stale_package_check = function(con) { + warning("This function is deprecated. Use lintr::unused_import_linter() instead") code = tryCatch(parse(con), error = identity) if (inherits(code, 'error')) { cat('Failed to parse R script, please fix syntax errors first\n') diff --git a/man/funchir-utils.Rd b/man/funchir-utils.Rd index 3093d37..540eac6 100644 --- a/man/funchir-utils.Rd +++ b/man/funchir-utils.Rd @@ -26,7 +26,7 @@ \item{dates}{ A vector of \code{Date}s. } } \value{ - \code{stale_package_check} reads a file (with \code{\link{readLines}}) and checks which functions are actually used from each loaded package. Currently only checks for \code{library} (i.e., not \code{require}) calls. + \code{stale_package_check} (DEPRECATED in favor of lintr::unused_import_linter) reads a file (with \code{\link{readLines}}) and checks which functions are actually used from each loaded package. Currently only checks for \code{library} (i.e., not \code{require}) calls. \code{embed.mat} inserts a supplied matrix into a (weakly) larger enclosing matrix, typically filled with 0s, at a specified position. diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 7b40493..dfb8f23 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -2,7 +2,7 @@ test_that('stale_package_check works', { stale_package_path <- function(path) test_path('stale_package_test_scripts', path) expect_output( - stale_package_check(stale_package_path('simple.R')), + expect_warning(stale_package_check(stale_package_path('simple.R')), "lintr::unused_import_linter"), paste( c("Functions matched from package stats:", paste0("\t", toString(sort(c("density", "rnorm")))), @@ -15,19 +15,19 @@ test_that('stale_package_check works', { ) expect_output( - stale_package_check(stale_package_path('use_namespace_call.R')), + expect_warning(stale_package_check(stale_package_path('use_namespace_call.R')), "lintr::unused_import_linter"), '**No exported functions matched from stats**', fixed = TRUE ) expect_output( - stale_package_check(stale_package_path('wont_parse.R')), + expect_warning(stale_package_check(stale_package_path('wont_parse.R')), "lintr::unused_import_linter"), 'Failed to parse R script, please fix syntax errors first', fixed = TRUE ) expect_output( - stale_package_check(stale_package_path('no_library.R')), + expect_warning(stale_package_check(stale_package_path('no_library.R')), "lintr::unused_import_linter"), 'No library() or require() calls found', fixed = TRUE )