diff --git a/R/fixed_regex_linter.R b/R/fixed_regex_linter.R index 46f4a57b5..5c456683c 100644 --- a/R/fixed_regex_linter.R +++ b/R/fixed_regex_linter.R @@ -154,7 +154,7 @@ fixed_regex_linter <- function(allow_unescaped = FALSE) { call_name <- xml_find_chr(patterns, "string(preceding-sibling::expr[last()]/SYMBOL_FUNCTION_CALL)") is_stringr <- startsWith(call_name, "str_") - replace_suggestion <- ifelse( + replacement_suggestion <- ifelse( is_stringr, sprintf("stringr::fixed(%s) as the pattern", fixed_equivalent), sprintf("%s with fixed = TRUE", fixed_equivalent) diff --git a/tests/testthat/test-class_equals_linter.R b/tests/testthat/test-class_equals_linter.R index d406e4a76..9487a4c6c 100644 --- a/tests/testthat/test-class_equals_linter.R +++ b/tests/testthat/test-class_equals_linter.R @@ -11,7 +11,7 @@ test_that("class_equals_linter skips allowed usages", { test_that("class_equals_linter blocks simple disallowed usages", { linter <- class_equals_linter() - lint_msg <- rex::rex("Use inherits(x, 'class-name') or is. or is(x, 'class')") + lint_msg <- rex::rex("Use inherits(x, 'class-name'), is. or is(x, 'class')") expect_lint("if (class(x) == 'character') stop('no')", lint_msg, linter) expect_lint("is_regression <- class(x) == 'lm'", lint_msg, linter) @@ -20,7 +20,7 @@ test_that("class_equals_linter blocks simple disallowed usages", { test_that("class_equals_linter blocks usage of %in% for checking class", { linter <- class_equals_linter() - lint_msg <- rex::rex("Use inherits(x, 'class-name') or is. or is(x, 'class')") + lint_msg <- rex::rex("Use inherits(x, 'class-name'), is. or is(x, 'class')") expect_lint("if ('character' %in% class(x)) stop('no')", lint_msg, linter) expect_lint("if (class(x) %in% 'character') stop('no')", lint_msg, linter) @@ -29,7 +29,7 @@ test_that("class_equals_linter blocks usage of %in% for checking class", { test_that("class_equals_linter blocks class(x) != 'klass'", { expect_lint( "if (class(x) != 'character') TRUE", - rex::rex("Use inherits(x, 'class-name') or is. or is(x, 'class')"), + rex::rex("Use inherits(x, 'class-name'), is. or is(x, 'class')"), class_equals_linter() ) }) @@ -43,7 +43,7 @@ test_that("class_equals_linter skips usage for subsetting", { # but not further nesting expect_lint( "x[if (class(x) == 'foo') 1 else 2]", - rex::rex("Use inherits(x, 'class-name') or is. or is(x, 'class')"), + rex::rex("Use inherits(x, 'class-name'), is. or is(x, 'class')"), linter ) }) diff --git a/tests/testthat/test-is_numeric_linter.R b/tests/testthat/test-is_numeric_linter.R index c3278a07f..ab235663c 100644 --- a/tests/testthat/test-is_numeric_linter.R +++ b/tests/testthat/test-is_numeric_linter.R @@ -20,7 +20,7 @@ test_that("is_numeric_linter skips allowed usages involving %in%", { test_that("is_numeric_linter blocks disallowed usages involving ||", { linter <- is_numeric_linter() - lint_msg <- rex::rex("Use `is.numeric(x)` instead of equivalent `is.numeric(x) || is.integer(x)`.") + lint_msg <- rex::rex("Use `is.numeric(x)` instead of the equivalent `is.numeric(x) || is.integer(x)`.") expect_lint("is.numeric(x) || is.integer(x)", lint_msg, linter) @@ -48,7 +48,7 @@ test_that("is_numeric_linter blocks disallowed usages involving ||", { test_that("is_numeric_linter blocks disallowed usages involving %in%", { linter <- is_numeric_linter() - lint_msg <- rex::rex('Use is.numeric(x) instead of equivalent class(x) %in% c("integer", "numeric")') + lint_msg <- rex::rex('Use is.numeric(x) instead of the equivalent class(x) %in% c("integer", "numeric")') expect_lint("class(x) %in% c('integer', 'numeric')", lint_msg, linter) expect_lint('class(x) %in% c("numeric", "integer")', lint_msg, linter) @@ -58,7 +58,7 @@ test_that("raw strings are handled properly when testing in class", { skip_if_not_r_version("4.0.0") linter <- is_numeric_linter() - lint_msg <- rex::rex('Use is.numeric(x) instead of equivalent class(x) %in% c("integer", "numeric")') + lint_msg <- rex::rex('Use is.numeric(x) instead of the equivalent class(x) %in% c("integer", "numeric")') expect_lint("class(x) %in% c(R'(numeric)', 'integer', 'factor')", NULL, linter) expect_lint("class(x) %in% c('numeric', R'--(integer)--', y)", NULL, linter)