From d92d504d48fe8e3a106f0f728b894f3c35bab9c4 Mon Sep 17 00:00:00 2001 From: Alexander Rosenstock Date: Sat, 16 Dec 2023 00:52:51 +0100 Subject: [PATCH] fix missing return from handle_expr_level_lints(), actually enable batching --- R/cyclocomp_linter.R | 2 +- R/lint.R | 4 +++- R/utils.R | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index 0c103f188..c5563646f 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -22,7 +22,7 @@ #' @seealso [linters] for a complete list of linters available in lintr. #' @export cyclocomp_linter <- function(complexity_limit = 15L) { - Linter(linter_level = "expression", supports_exprlist = TRUE, function(source_expression) { + Linter(linter_level = "expression", function(source_expression) { complexity <- try_silently( cyclocomp::cyclocomp(parse(text = source_expression$content)) ) diff --git a/R/lint.R b/R/lint.R index 367afaeb6..4f5ddb5b8 100644 --- a/R/lint.R +++ b/R/lint.R @@ -791,7 +791,7 @@ collapse_exprs <- function(expr_list) { for (expr in expr_list) { i <- i + 1L xml2::xml_add_child(xml_pc, expr$xml_parsed_content) - function_call_cache <- c(function_call_cache, expr$xml_find_function_calls(NULL, keep_names = TRUE)) + function_call_cache <- combine_nodesets(function_call_cache, expr$xml_find_function_calls(NULL, keep_names = TRUE)) lines <- c(lines, expr$lines) parsed_content <- if (is.null(parsed_content)) expr$parsed_content else rbind(parsed_content, expr$parsed_content) content <- paste(content, expr$content, sep = "\n") @@ -872,4 +872,6 @@ handle_expr_level_lints <- function(lints, expression_linter_names, supports_exp exprs_to_lint <- exprs_expression[!expr_linter_cached[, linter_name]] lints[[length(lints) + 1L]] <- get_lints_batched(exprs_to_lint, linter_name, linter_fun, lint_cache, filename) } + + lints } \ No newline at end of file diff --git a/R/utils.R b/R/utils.R index 88c93db97..51e5e4b00 100644 --- a/R/utils.R +++ b/R/utils.R @@ -178,6 +178,7 @@ Linter <- function(fun, name = linter_auto_name(), linter_level = c(NA_character class(fun) <- c("linter", "function") attr(fun, "name") <- name attr(fun, "linter_level") <- linter_level + attr(fun, "linter_exprlist") <- isTRUE(supports_exprlist) fun }