From 98a6962f91f548cfd09ab110f21a8d2219857693 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sat, 25 Feb 2023 22:43:58 +0000 Subject: [PATCH] use specific imports for rex --- NAMESPACE | 6 +++++- R/lintr-package.R | 2 +- tests/testthat/test-fixed_regex_linter.R | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7e05e77be..bcb9dde0c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -137,8 +137,12 @@ export(with_defaults) export(with_id) export(xml_nodes_to_lints) export(yoda_test_linter) -import(rex) importFrom(cyclocomp,cyclocomp) +importFrom(rex,character_class) +importFrom(rex,re_matches) +importFrom(rex,re_substitutes) +importFrom(rex,regex) +importFrom(rex,rex) importFrom(stats,na.omit) importFrom(utils,capture.output) importFrom(utils,getParseData) diff --git a/R/lintr-package.R b/R/lintr-package.R index c0d4e2499..7ee7a3115 100644 --- a/R/lintr-package.R +++ b/R/lintr-package.R @@ -8,7 +8,7 @@ "_PACKAGE" ## lintr namespace: start -#' @import rex +#' @importFrom rex rex regex re_matches re_substitutes character_class #' @importFrom stats na.omit #' @importFrom utils capture.output head getParseData relist #' @importFrom xml2 xml_find_all as_list diff --git a/tests/testthat/test-fixed_regex_linter.R b/tests/testthat/test-fixed_regex_linter.R index 8ffd419af..535912bec 100644 --- a/tests/testthat/test-fixed_regex_linter.R +++ b/tests/testthat/test-fixed_regex_linter.R @@ -59,14 +59,14 @@ patrick::with_parameters_test_that( fixed_regex_linter() ) }, - .cases = data.frame( - char = c( + .cases = local({ + char <- c( "^", "$", "{", "}", "(", ")", ".", "*", "+", "?", "|", "[", "]", "\\\\", "<", ">", "=", ":", ";", "/", "_", "-", "!", "@", "#", "%", "&", "~" - ), - stringsAsFactors = FALSE - ) + ) + data.frame(char = char, .test_name = char, stringsAsFactors = FALSE) + }) ) test_that("fixed_regex_linter catches regex like [.] or [$]", {