From ef82966a21bf5118ec2828d58ca02287dfb02074 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 20 Nov 2023 22:20:53 -0800 Subject: [PATCH] Use implicit returns (#2324) --- R/any_duplicated_linter.R | 2 +- R/comments.R | 4 ++-- R/inner_combine_linter.R | 4 ++-- R/package_hooks_linter.R | 4 ++-- R/redundant_ifelse_linter.R | 2 +- R/regex_subset_linter.R | 2 +- R/scalar_in_linter.R | 4 ++-- R/xp_utils.R | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/R/any_duplicated_linter.R b/R/any_duplicated_linter.R index b7ad6af07..eb75eb7fe 100644 --- a/R/any_duplicated_linter.R +++ b/R/any_duplicated_linter.R @@ -113,6 +113,6 @@ any_duplicated_linter <- function() { type = "warning" ) - return(c(any_duplicated_lints, length_unique_lints)) + c(any_duplicated_lints, length_unique_lints) }) } diff --git a/R/comments.R b/R/comments.R index 40d7b1aba..491b99203 100644 --- a/R/comments.R +++ b/R/comments.R @@ -42,7 +42,7 @@ jenkins_build_info <- function() { } in_travis <- function() { - return(nzchar(Sys.getenv("TRAVIS_REPO_SLUG"))) + nzchar(Sys.getenv("TRAVIS_REPO_SLUG")) } travis_build_info <- function() { @@ -59,7 +59,7 @@ travis_build_info <- function() { } in_wercker <- function() { - return(nzchar(Sys.getenv("WERCKER_GIT_BRANCH"))) + nzchar(Sys.getenv("WERCKER_GIT_BRANCH")) } ci_build_info <- function() { diff --git a/R/inner_combine_linter.R b/R/inner_combine_linter.R index 2b1f22af8..5508b31c1 100644 --- a/R/inner_combine_linter.R +++ b/R/inner_combine_linter.R @@ -112,7 +112,7 @@ arg_match_condition <- function(arg) { this_symbol <- sprintf("SYMBOL_SUB[text() = '%s']", arg) following_symbol <- sprintf("following-sibling::expr/%s", this_symbol) next_expr <- "following-sibling::expr[1]" - return(xp_or( + xp_or( sprintf("not(%s) and not(%s)", this_symbol, following_symbol), xp_and( this_symbol, @@ -122,7 +122,7 @@ arg_match_condition <- function(arg) { this_symbol, following_symbol, next_expr ) ) - )) + ) } build_arg_condition <- function(calls, arguments) { diff --git a/R/package_hooks_linter.R b/R/package_hooks_linter.R index 40be40a30..a0575b2ad 100644 --- a/R/package_hooks_linter.R +++ b/R/package_hooks_linter.R @@ -183,13 +183,13 @@ package_hooks_linter <- function() { unload_arg_name_lints <- xml_nodes_to_lints(unload_arg_name_expr, source_expression, unload_arg_name_message, type = "warning") - return(c( + c( onload_bad_msg_call_lints, onattach_bad_msg_call_lints, load_arg_name_lints, library_require_lints, bad_unload_call_lints, unload_arg_name_lints - )) + ) }) } diff --git a/R/redundant_ifelse_linter.R b/R/redundant_ifelse_linter.R index 82944939e..e0bface5f 100644 --- a/R/redundant_ifelse_linter.R +++ b/R/redundant_ifelse_linter.R @@ -108,6 +108,6 @@ redundant_ifelse_linter <- function(allow10 = FALSE) { lints <- c(lints, xml_nodes_to_lints(num_expr, source_expression, lint_message, type = "warning")) } - return(lints) + lints }) } diff --git a/R/regex_subset_linter.R b/R/regex_subset_linter.R index aaf026058..115a7e21e 100644 --- a/R/regex_subset_linter.R +++ b/R/regex_subset_linter.R @@ -94,6 +94,6 @@ regex_subset_linter <- function() { type = "warning" ) - return(c(grep_lints, stringr_lints)) + c(grep_lints, stringr_lints) }) } diff --git a/R/scalar_in_linter.R b/R/scalar_in_linter.R index 078dad16b..f2d227e06 100644 --- a/R/scalar_in_linter.R +++ b/R/scalar_in_linter.R @@ -37,7 +37,7 @@ scalar_in_linter <- function() { /parent::expr " - return(Linter(function(source_expression) { + Linter(function(source_expression) { if (!is_lint_level(source_expression, "expression")) { return(list()) } @@ -55,5 +55,5 @@ scalar_in_linter <- function() { lint_message = lint_msg, type = "warning" ) - })) + }) } diff --git a/R/xp_utils.R b/R/xp_utils.R index b48e82c51..3264ffdef 100644 --- a/R/xp_utils.R +++ b/R/xp_utils.R @@ -11,7 +11,7 @@ xp_text_in_table <- function(table) { single_quoted <- grepl("'", table, fixed = TRUE) table[single_quoted] <- sQuote(table[single_quoted], '"') table[!single_quoted] <- sQuote(table[!single_quoted], "'") - return(paste0("text() = ", table, collapse = " or ")) + paste0("text() = ", table, collapse = " or ") } paren_wrap <- function(..., sep) {