From 7348f6fbd3c9c6cf6f884602a2d5476ad3e61e8c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 15 Jun 2022 22:08:58 -0500 Subject: [PATCH] [ci] [R-package] upgrade to lintr v3.0 (fixes #5228) --- .ci/lint_r_code.R | 44 +++++++++++++++++++++----------------------- .ci/test.sh | 2 +- build_r.R | 2 +- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.ci/lint_r_code.R b/.ci/lint_r_code.R index d477a1a70b9c..90fe9481c741 100755 --- a/.ci/lint_r_code.R +++ b/.ci/lint_r_code.R @@ -29,28 +29,26 @@ interactive_text <- paste0( ) LINTERS_TO_USE <- list( - "absolute_path" = lintr::absolute_path_linter - , "assignment" = lintr::assignment_linter - , "closed_curly" = lintr::closed_curly_linter - , "commas" = lintr::commas_linter - , "equals_na" = lintr::equals_na_linter - , "function_left" = lintr::function_left_parentheses_linter - , "implicit_integers" = lintr::implicit_integer_linter - , "infix_spaces" = lintr::infix_spaces_linter + "absolute_path" = lintr::absolute_path_linter() + , "assignment" = lintr::assignment_linter() + , "braces" = lintr::brace_linter() + , "commas" = lintr::commas_linter() + , "equals_na" = lintr::equals_na_linter() + , "function_left" = lintr::function_left_parentheses_linter() + , "implicit_integers" = lintr::implicit_integer_linter() + , "infix_spaces" = lintr::infix_spaces_linter() , "long_lines" = lintr::line_length_linter(length = 120L) - , "no_tabs" = lintr::no_tab_linter - , "non_portable_path" = lintr::nonportable_path_linter - , "open_curly" = lintr::open_curly_linter - , "paren_brace_linter" = lintr::paren_brace_linter - , "semicolon" = lintr::semicolon_terminator_linter - , "seq" = lintr::seq_linter - , "single_quotes" = lintr::single_quotes_linter - , "spaces_inside" = lintr::spaces_inside_linter - , "spaces_left_parens" = lintr::spaces_left_parentheses_linter + , "no_tabs" = lintr::no_tab_linter() + , "non_portable_path" = lintr::nonportable_path_linter() + , "semicolon" = lintr::semicolon_linter() + , "seq" = lintr::seq_linter() + , "single_quotes" = lintr::single_quotes_linter() + , "spaces_inside" = lintr::spaces_inside_linter() + , "spaces_left_parens" = lintr::spaces_left_parentheses_linter() , "todo_comments" = lintr::todo_comment_linter(c("todo", "fixme", "to-do")) - , "trailing_blank" = lintr::trailing_blank_lines_linter - , "trailing_white" = lintr::trailing_whitespace_linter - , "true_false" = lintr::T_and_F_symbol_linter + , "trailing_blank" = lintr::trailing_blank_lines_linter() + , "trailing_white" = lintr::trailing_whitespace_linter() + , "true_false" = lintr::T_and_F_symbol_linter() , "undesirable_function" = lintr::undesirable_function_linter( fun = c( "cat" = "CRAN forbids the use of cat() in packages except in special cases. Use message() or warning()." @@ -58,8 +56,8 @@ LINTERS_TO_USE <- list( "cbind is an unsafe way to build up a data frame. merge() or direct " , "column assignment is preferred." ) - , "dyn.load" = "Directly loading/unloading .dll/.so files in package code should not be necessary." - , "dyn.unload" = "Directly loading/unloading .dll/.so files in package code should not be necessary." + , "dyn.load" = "Directly loading or unloading .dll or .so files in package code should not be necessary." + , "dyn.unload" = "Directly loading or unloading .dll or .so files in package code should not be necessary." , "help" = interactive_text , "ifelse" = "The use of ifelse() is dangerous because it will silently allow mixing types." , "install.packages" = interactive_text @@ -83,7 +81,7 @@ LINTERS_TO_USE <- list( , "??" = interactive_text ) ) - , "unneeded_concatenation" = lintr::unneeded_concatenation_linter + , "unneeded_concatenation" = lintr::unneeded_concatenation_linter() ) noquote(paste0(length(FILES_TO_LINT), " R files need linting")) diff --git a/.ci/test.sh b/.ci/test.sh index 3f963c52fd81..e549416d55da 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -75,7 +75,7 @@ if [[ $TASK == "lint" ]]; then mypy \ pycodestyle \ pydocstyle \ - "r-lintr>=2.0,<3.0" + "r-lintr>=3.0" echo "Linting Python code" pycodestyle --ignore=E501,W503 --exclude=./.nuget,./external_libs . || exit -1 pydocstyle --convention=numpy --add-ignore=D105 --match-dir="^(?!^external_libs|test|example).*" --match="(?!^test_|setup).*\.py" . || exit -1 diff --git a/build_r.R b/build_r.R index dbf225e25f70..c66e1ceecce3 100644 --- a/build_r.R +++ b/build_r.R @@ -24,7 +24,7 @@ TEMP_SOURCE_DIR <- file.path(TEMP_R_DIR, "src") , "make_args" = character(0L) ) for (arg in args) { - if (any(grepl("^\\-j[0-9]+", arg))) { + if (any(grepl("^\\-j[0-9]+", arg))) { # nolint: non_portable_path out_list[["make_args"]] <- arg } else if (any(grepl("=", arg))) { split_arg <- strsplit(arg, "=")[[1L]]