From 1e9b93d06a58843a398c3536f5575ccb951ef6e9 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 9 Nov 2022 22:18:06 +0100 Subject: [PATCH] Remove `undesirable_operator_linter()` from `.lintr_new` (#1767) * Remove `undesirable_operator_linter` from `.lintr_new` Closes #1766 Add it back once #1692 is resolved * Update test-settings.R * remaining --- .lintr_new | 1 - R/expect_lint.R | 2 +- R/get_source_expressions.R | 2 +- R/lint.R | 2 +- R/object_usage_linter.R | 2 +- R/utils.R | 6 +++--- R/zzz.R | 4 ++-- tests/testthat/test-settings.R | 3 --- 8 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.lintr_new b/.lintr_new index 4e9195d35..b3aabf487 100644 --- a/.lintr_new +++ b/.lintr_new @@ -23,7 +23,6 @@ linters: linters_with_defaults( redundant_ifelse_linter(), sprintf_linter(), strings_as_factors_linter(), - undesirable_operator_linter(), unnecessary_lambda_linter(), unneeded_concatenation_linter(allow_single_expression = FALSE), yoda_test_linter() diff --git a/R/expect_lint.R b/R/expect_lint.R index 9d041d9e3..5031c4aaa 100644 --- a/R/expect_lint.R +++ b/R/expect_lint.R @@ -84,7 +84,7 @@ expect_lint <- function(content, checks, ..., file = NULL, language = "en") { lint_fields <- unique(c(names(formals(Lint)), "linter")) Map( function(lint, check) { - itr <<- itr + 1L # nolint: undesirable_operator. + itr <<- itr + 1L lapply(names(check), function(field) { if (!field %in% lint_fields) { stop(sprintf( diff --git a/R/get_source_expressions.R b/R/get_source_expressions.R index cd2ab6aa8..0495599d2 100644 --- a/R/get_source_expressions.R +++ b/R/get_source_expressions.R @@ -588,7 +588,7 @@ tab_offsets <- function(tab_columns) { tab_columns - 1L, function(tab_idx) { offset <- 7L - (tab_idx + cum_offset) %% 8L # using a tab width of 8 characters - cum_offset <<- cum_offset + offset # nolint: undesirable_operator. + cum_offset <<- cum_offset + offset offset }, integer(1L), diff --git a/R/lint.R b/R/lint.R index 222982cb0..586dfcefe 100644 --- a/R/lint.R +++ b/R/lint.R @@ -667,7 +667,7 @@ highlight_string <- function(message, column_number = NULL, ranges = NULL) { line <- fill_with(" ", maximum) lapply(ranges, function(range) { - substr(line, range[1L], range[2L]) <<- fill_with("~", range[2L] - range[1L] + 1L) # nolint: undesirable_operator. + substr(line, range[1L], range[2L]) <<- fill_with("~", range[2L] - range[1L] + 1L) }) substr(line, column_number, column_number + 1L) <- "^" diff --git a/R/object_usage_linter.R b/R/object_usage_linter.R index d425bb616..b1c94b3e6 100644 --- a/R/object_usage_linter.R +++ b/R/object_usage_linter.R @@ -248,7 +248,7 @@ parse_check_usage <- function(expression, vals <- list() report <- function(x) { - vals[[length(vals) + 1L]] <<- x # nolint: undesirable_operator. + vals[[length(vals) + 1L]] <<- x } withr::with_options( diff --git a/R/utils.R b/R/utils.R index 779659e1b..e3c814458 100644 --- a/R/utils.R +++ b/R/utils.R @@ -28,8 +28,8 @@ flatten_list <- function(x, class) { itr <- 1L assign_item <- function(x) { if (inherits(x, class)) { - res[[itr]] <<- x # nolint: undesirable_operator. - itr <<- itr + 1L # nolint: undesirable_operator. + res[[itr]] <<- x + itr <<- itr + 1L } else if (is.list(x)) { lapply(x, assign_item) } @@ -174,7 +174,7 @@ read_lines <- function(file, encoding = settings$encoding, ...) { readLines(file, warn = TRUE, ...), warning = function(w) { if (grepl("incomplete final line found on", w$message, fixed = TRUE)) { - terminal_newline <<- FALSE # nolint: undesirable_operator. + terminal_newline <<- FALSE invokeRestart("muffleWarning") } } diff --git a/R/zzz.R b/R/zzz.R index 760df5f7e..1e6be7915 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -295,7 +295,7 @@ settings <- NULL } } - default_settings <<- list( # nolint: undesirable_operator. + default_settings <<- list( linters = default_linters, encoding = "UTF-8", exclude = rex::rex("#", any_spaces, "nolint"), @@ -325,7 +325,7 @@ settings <- NULL error_on_lint = logical_env("LINTR_ERROR_ON_LINT") %||% FALSE ) - settings <<- list2env(default_settings, parent = emptyenv()) # nolint: undesirable_operator. + settings <<- list2env(default_settings, parent = emptyenv()) invisible() } # nocov end diff --git a/tests/testthat/test-settings.R b/tests/testthat/test-settings.R index 9024f52fd..3ee128c02 100644 --- a/tests/testthat/test-settings.R +++ b/tests/testthat/test-settings.R @@ -1,5 +1,3 @@ -# nolint start: undesirable_operator. -# This test file tests multiple internal lintr functions, so we need to allow lintr:::* test_that("it uses default settings if none provided", { lintr:::read_settings(NULL) @@ -121,4 +119,3 @@ test_that("it has a smart default for encodings", { lintr:::read_settings(pkg_file) expect_identical(settings$encoding, "ISO8859-1") }) -# nolint end