From 2abb091ddc0ed89753150b5400dcb44993003364 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 30 Nov 2025 06:45:17 +0000 Subject: [PATCH 1/3] Initial call site selection for |> --- R/exclude.R | 12 +++++------- R/lint.R | 9 +++++---- R/linter_tags.R | 6 ++++-- R/settings.R | 9 +++------ R/utils.R | 5 +++-- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/R/exclude.R b/R/exclude.R index 6033f1226..aa9cc09a4 100644 --- a/R/exclude.R +++ b/R/exclude.R @@ -346,13 +346,11 @@ normalize_exclusions <- function(x, normalize_path = TRUE, x <- x[file.exists(paths)] # remove exclusions for non-existing files names(x) <- normalize_path(names(x)) # get full path for remaining files } - remove_line_duplicates( - remove_linter_duplicates( - remove_file_duplicates( - remove_empty(x) - ) - ) - ) + x |> + remove_empty() |> + remove_file_duplicates() |> + remove_linter_duplicates() |> + remove_line_duplicates() } # Combines file exclusions for identical files. diff --git a/R/lint.R b/R/lint.R index 49fe83e1d..20040dd59 100644 --- a/R/lint.R +++ b/R/lint.R @@ -78,8 +78,10 @@ lint <- function(filename, linters = NULL, ..., cache = FALSE, parse_settings = lints <- lint_impl_(linters, lint_cache, filename, source_expressions) - lints <- maybe_append_condition_lints(lints, source_expressions, lint_cache, filename) - lints <- reorder_lints(flatten_lints(lints)) + lints <- + maybe_append_condition_lints(lints, source_expressions, lint_cache, filename) |> + flatten_lints() |> + reorder_lints() class(lints) <- c("lints", "list") cache_file(lint_cache, filename, linters, lints) @@ -209,8 +211,7 @@ lint_dir <- function(path = ".", ..., ) } - lints <- flatten_lints(lints) - lints <- reorder_lints(lints) + lints <- flatten_lints(lints) |> reorder_lints() if (relative_path) { path <- normalize_path(path, mustWork = FALSE) diff --git a/R/linter_tags.R b/R/linter_tags.R index e9bebf1da..f151c86c8 100644 --- a/R/linter_tags.R +++ b/R/linter_tags.R @@ -132,8 +132,10 @@ validate_linter_db <- function(available, package) { #' @examples #' available_tags() available_tags <- function(packages = "lintr") { - platform_independent_sort(unique(unlist(available_linters(packages = packages, exclude_tags = NULL)[["tags"]]))) -} + available_linters(packages = packages, exclude_tags = NULL)[["tags"]] |> + unlist() |> + unique() |> + platform_independent_sort()} # nocov start diff --git a/R/settings.R b/R/settings.R index 7577f3d8b..407c4ead2 100644 --- a/R/settings.R +++ b/R/settings.R @@ -283,12 +283,9 @@ find_default_encoding <- function(filename) { return(NULL) } - root_path <- find_package(filename, allow_rproj = TRUE) - rproj_enc <- get_encoding_from_dcf(find_rproj_at(root_path)) - if (!is.null(rproj_enc)) { - return(rproj_enc) - } - rproj_enc + find_package(filename, allow_rproj = TRUE) |> + find_rproj_at() |> + get_encoding_from_dcf() } get_encoding_from_dcf <- function(file) { diff --git a/R/utils.R b/R/utils.R index 6ff2ead83..2462f647f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -54,8 +54,9 @@ linter_auto_name <- function(which = -3L) { regex <- rex(start, one_or_more(alnum %or% "." %or% "_" %or% ":")) if (re_matches(nm, regex)) { match_data <- re_matches(nm, regex, locations = TRUE) - nm <- substr(nm, start = 1L, stop = match_data[1L, "end"]) - nm <- re_substitutes(nm, rex(start, alnums, "::"), "") + nm <- nm |> + substr(start = 1L, stop = match_data[1L, "end"]) |> + re_substitutes(rex(start, alnums, "::"), "") } nm } From 08aeba090207869c905abfa1fba836453dd4eef0 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 30 Nov 2025 06:51:25 +0000 Subject: [PATCH 2/3] follow-up pass --- R/lint.R | 6 +++--- R/linter_tags.R | 3 ++- R/settings.R | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/R/lint.R b/R/lint.R index 20040dd59..24488a1d0 100644 --- a/R/lint.R +++ b/R/lint.R @@ -78,8 +78,8 @@ lint <- function(filename, linters = NULL, ..., cache = FALSE, parse_settings = lints <- lint_impl_(linters, lint_cache, filename, source_expressions) - lints <- - maybe_append_condition_lints(lints, source_expressions, lint_cache, filename) |> + lints <- lints |> + maybe_append_condition_lints(source_expressions, lint_cache, filename) |> flatten_lints() |> reorder_lints() class(lints) <- c("lints", "list") @@ -211,7 +211,7 @@ lint_dir <- function(path = ".", ..., ) } - lints <- flatten_lints(lints) |> reorder_lints() + lints <- reorder_lints(flatten_lints(lints)) if (relative_path) { path <- normalize_path(path, mustWork = FALSE) diff --git a/R/linter_tags.R b/R/linter_tags.R index f151c86c8..373f94360 100644 --- a/R/linter_tags.R +++ b/R/linter_tags.R @@ -135,7 +135,8 @@ available_tags <- function(packages = "lintr") { available_linters(packages = packages, exclude_tags = NULL)[["tags"]] |> unlist() |> unique() |> - platform_independent_sort()} + platform_independent_sort() +} # nocov start diff --git a/R/settings.R b/R/settings.R index 407c4ead2..2fc94f7de 100644 --- a/R/settings.R +++ b/R/settings.R @@ -283,7 +283,8 @@ find_default_encoding <- function(filename) { return(NULL) } - find_package(filename, allow_rproj = TRUE) |> + filename |> + find_package(allow_rproj = TRUE) |> find_rproj_at() |> get_encoding_from_dcf() } From 86c73c96ab888d295773400a79c558270a2496cd Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 30 Nov 2025 06:52:29 +0000 Subject: [PATCH 3/3] restore --- R/lint.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/lint.R b/R/lint.R index 24488a1d0..2028e938f 100644 --- a/R/lint.R +++ b/R/lint.R @@ -211,7 +211,8 @@ lint_dir <- function(path = ".", ..., ) } - lints <- reorder_lints(flatten_lints(lints)) + lints <- flatten_lints(lints) + lints <- reorder_lints(lints) if (relative_path) { path <- normalize_path(path, mustWork = FALSE)