Skip to content

Commit

Permalink
Remove undesirable_operator_linter() from .lintr_new (#1767)
Browse files Browse the repository at this point in the history
* Remove `undesirable_operator_linter` from `.lintr_new`

Closes #1766

Add it back once #1692 is resolved

* Update test-settings.R

* remaining
  • Loading branch information
IndrajeetPatil authored Nov 9, 2022
1 parent 7a4fcee commit 1e9b93d
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion .lintr_new
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion R/expect_lint.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion R/get_source_expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion R/lint.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) <- "^"
Expand Down
2 changes: 1 addition & 1 deletion R/object_usage_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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")
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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
3 changes: 0 additions & 3 deletions tests/testthat/test-settings.R
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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

0 comments on commit 1e9b93d

Please sign in to comment.