diff --git a/DESCRIPTION b/DESCRIPTION index 3ec0b6efb..6a456f3a9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,7 +21,7 @@ License: MIT + file LICENSE URL: https://github.com/r-lib/lintr, https://lintr.r-lib.org BugReports: https://github.com/r-lib/lintr/issues Depends: - R (>= 3.5) + R (>= 3.6) Imports: backports (>= 1.1.7), codetools, diff --git a/R/settings.R b/R/settings.R index cedc289fa..05447ee33 100644 --- a/R/settings.R +++ b/R/settings.R @@ -56,7 +56,7 @@ read_config_file <- function(config_file) { config <- new.env() if (endsWith(config_file, ".R")) { - load_config <- function(file) sys_source(file, config) + load_config <- function(file) sys.source(file, config, keep.source = FALSE, keep.parse.data = FALSE) malformed <- function(e) { stop("Malformed config file, ensure it is valid R syntax\n ", conditionMessage(e), call. = FALSE) } @@ -231,10 +231,7 @@ get_encoding_from_dcf <- function(file) { warning = function(e) NULL ) - if (!is.null(encodings)) { - # Produces a warning in R <= 3.5 if encoding is NULL - encodings <- encodings[!is.na(encodings)] - } + encodings <- encodings[!is.na(encodings)] if (length(encodings) > 0L) { return(encodings[1L]) } diff --git a/R/shared_constants.R b/R/shared_constants.R index de3ac199e..831545b9a 100644 --- a/R/shared_constants.R +++ b/R/shared_constants.R @@ -164,7 +164,7 @@ names(infix_metadata) <- c("xml_tag", "string_value") # utils::getParseData()'s designation for the tokens wouldn't be valid as XML tags infix_metadata$parse_tag <- ifelse( startsWith(infix_metadata$xml_tag, "OP-"), - quote_wrap(infix_metadata$string_value, "'"), + sQuote(infix_metadata$string_value, "'"), infix_metadata$xml_tag ) # treated separately because spacing rules are different for unary operators diff --git a/R/utils.R b/R/utils.R index b9ee39d9c..6b2e054df 100644 --- a/R/utils.R +++ b/R/utils.R @@ -138,9 +138,6 @@ try_silently <- function(expr) { ) } -# imitate sQuote(x, q) [requires R>=3.6] -quote_wrap <- function(x, q) paste0(q, x, q) - # interface to work like options() or setwd() -- returns the old value for convenience set_lang <- function(new_lang) { old_lang <- Sys.getenv("LANGUAGE", unset = NA) diff --git a/R/xp_utils.R b/R/xp_utils.R index 1a599d727..b48e82c51 100644 --- a/R/xp_utils.R +++ b/R/xp_utils.R @@ -9,8 +9,8 @@ xp_text_in_table <- function(table) { # to use "" whenever the string has ' (not a perfect solution). info on # escaping from https://stackoverflow.com/questions/14822153 single_quoted <- grepl("'", table, fixed = TRUE) - table[single_quoted] <- quote_wrap(table[single_quoted], '"') - table[!single_quoted] <- quote_wrap(table[!single_quoted], "'") + table[single_quoted] <- sQuote(table[single_quoted], '"') + table[!single_quoted] <- sQuote(table[!single_quoted], "'") return(paste0("text() = ", table, collapse = " or ")) } diff --git a/R/zzz.R b/R/zzz.R index 226063c9b..411c7e462 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -282,18 +282,6 @@ default_undesirable_operators <- all_undesirable_operators[names(all_undesirable #' @export default_settings <- NULL -# TODO(R>=3.6.0): Just use sys.source() directly. Note that we can't -# write a wrapper that only passes keep.parse.data=FALSE on R>3.5.0 -# (without doing some wizardry to evade R CMD check) because -# there is a check for arguments not matching the signature which -# will throw a false positive on R3.5.0. Luckily the argument -# defaults on R>=3.6.0 are dictated by global options, so we can use -# that for the wrapper here rather than doing some NSE tricks. -sys_source <- function(...) { - old <- options(keep.source.pkgs = FALSE, keep.parse.data.pkgs = FALSE) - on.exit(options(old)) - sys.source(...) -} settings <- new.env(parent = emptyenv()) # nocov start @@ -305,18 +293,9 @@ settings <- new.env(parent = emptyenv()) toset <- !(names(op_lintr) %in% names(op)) if (any(toset)) options(op_lintr[toset]) - # R>=3.6.0: str2expression, str2lang # R>=4.0.0: deparse1 # R>=4.1.0: ...names backports::import(pkgname, c("deparse1", "...names")) - base_ns <- getNamespace("base") - backports_ns <- getNamespace("backports") - lintr_ns <- getNamespace(pkgname) - for (base_fun in c("str2lang", "str2expression")) { - if (!exists(base_fun, base_ns)) { - assign(base_fun, get(base_fun, backports_ns), lintr_ns) - } - } utils::assignInMyNamespace("default_settings", list( linters = default_linters, diff --git a/tests/testthat/test-lint_package.R b/tests/testthat/test-lint_package.R index ae95bdde6..957b8af9c 100644 --- a/tests/testthat/test-lint_package.R +++ b/tests/testthat/test-lint_package.R @@ -231,7 +231,6 @@ test_that("package using .lintr.R config lints correctly", { }) test_that("lintr need not be attached for .lintr.R configs to use lintr functions", { - skip_if_not_r_version("3.6.0") # unclear error message exprs <- paste( 'options(lintr.linter_file = "lintr_test_config")', sprintf('lints <- lintr::lint_package("%s")', test_path("dummy_packages", "RConfig")),