From ad71db53ab6c68d604316457992e622e8324b606 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 13 Apr 2024 16:52:17 +0200 Subject: [PATCH 01/20] Make `cyclocomp_linter()` optional closes #2554 --- DESCRIPTION | 2 +- R/cyclocomp_linter.R | 4 ++-- R/zzz.R | 1 - inst/lintr/linters.csv | 2 +- man/cyclocomp_linter.Rd | 7 ++++--- man/default_linters.Rd | 3 +-- man/linters.Rd | 4 ++-- tests/testthat/test-cyclocomp_linter.R | 2 ++ 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ceecd0227e..900b0a37db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,7 +25,6 @@ Depends: Imports: backports (>= 1.1.7), codetools, - cyclocomp, digest, glue, knitr, @@ -37,6 +36,7 @@ Imports: Suggests: bookdown, cli, + cyclocomp, jsonlite, patrick (>= 0.2.0), rlang, diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index c5563646f2..d9f20882a2 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -2,10 +2,10 @@ #' #' Check for overly complicated expressions. See [cyclocomp::cyclocomp()]. #' -#' @param complexity_limit Maximum cyclomatic complexity, default 15. Expressions more complex +#' @param complexity_limit Maximum cyclomatic complexity, default `15`. Expressions more complex #' than this are linted. See [cyclocomp::cyclocomp()]. #' -#' @examples +#' @examplesIf requireNamespace("cyclocomp", quietly = TRUE) #' # will produce lints #' lint( #' text = "if (TRUE) 1 else 2", diff --git a/R/zzz.R b/R/zzz.R index a135938a82..2915392974 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -17,7 +17,6 @@ default_linters <- modify_defaults( brace_linter(), commas_linter(), commented_code_linter(), - cyclocomp_linter(), equals_na_linter(), function_left_parentheses_linter(), indentation_linter(), diff --git a/inst/lintr/linters.csv b/inst/lintr/linters.csv index f6d6147750..539cdbc984 100644 --- a/inst/lintr/linters.csv +++ b/inst/lintr/linters.csv @@ -17,7 +17,7 @@ conjunct_test_linter,package_development best_practices readability configurable consecutive_assertion_linter,style readability consistency consecutive_mutate_linter,consistency readability configurable efficiency consecutive_stopifnot_linter,style readability consistency deprecated -cyclocomp_linter,style readability best_practices default configurable +cyclocomp_linter,style readability best_practices configurable duplicate_argument_linter,correctness common_mistakes configurable empty_assignment_linter,readability best_practices equals_na_linter,robustness correctness common_mistakes default diff --git a/man/cyclocomp_linter.Rd b/man/cyclocomp_linter.Rd index 59a376cdfa..e4abbd741a 100644 --- a/man/cyclocomp_linter.Rd +++ b/man/cyclocomp_linter.Rd @@ -7,13 +7,14 @@ cyclocomp_linter(complexity_limit = 15L) } \arguments{ -\item{complexity_limit}{Maximum cyclomatic complexity, default 15. Expressions more complex +\item{complexity_limit}{Maximum cyclomatic complexity, default \code{15}. Expressions more complex than this are linted. See \code{\link[cyclocomp:cyclocomp]{cyclocomp::cyclocomp()}}.} } \description{ Check for overly complicated expressions. See \code{\link[cyclocomp:cyclocomp]{cyclocomp::cyclocomp()}}. } \examples{ +\dontshow{if (requireNamespace("cyclocomp", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # will produce lints lint( text = "if (TRUE) 1 else 2", @@ -25,11 +26,11 @@ lint( text = "if (TRUE) 1 else 2", linters = cyclocomp_linter(complexity_limit = 2L) ) - +\dontshow{\}) # examplesIf} } \seealso{ \link{linters} for a complete list of linters available in lintr. } \section{Tags}{ -\link[=best_practices_linters]{best_practices}, \link[=configurable_linters]{configurable}, \link[=default_linters]{default}, \link[=readability_linters]{readability}, \link[=style_linters]{style} +\link[=best_practices_linters]{best_practices}, \link[=configurable_linters]{configurable}, \link[=readability_linters]{readability}, \link[=style_linters]{style} } diff --git a/man/default_linters.Rd b/man/default_linters.Rd index f14177a9ac..cdaa763c7b 100644 --- a/man/default_linters.Rd +++ b/man/default_linters.Rd @@ -5,7 +5,7 @@ \alias{default_linters} \title{Default linters} \format{ -An object of class \code{list} of length 26. +An object of class \code{list} of length 25. } \usage{ default_linters @@ -29,7 +29,6 @@ The following linters are tagged with 'default': \item{\code{\link{brace_linter}}} \item{\code{\link{commas_linter}}} \item{\code{\link{commented_code_linter}}} -\item{\code{\link{cyclocomp_linter}}} \item{\code{\link{equals_na_linter}}} \item{\code{\link{function_left_parentheses_linter}}} \item{\code{\link{indentation_linter}}} diff --git a/man/linters.Rd b/man/linters.Rd index 10c45d3746..d2ba40da16 100644 --- a/man/linters.Rd +++ b/man/linters.Rd @@ -22,7 +22,7 @@ The following tags exist: \item{\link[=configurable_linters]{configurable} (43 linters)} \item{\link[=consistency_linters]{consistency} (32 linters)} \item{\link[=correctness_linters]{correctness} (7 linters)} -\item{\link[=default_linters]{default} (26 linters)} +\item{\link[=default_linters]{default} (25 linters)} \item{\link[=deprecated_linters]{deprecated} (6 linters)} \item{\link[=efficiency_linters]{efficiency} (32 linters)} \item{\link[=executing_linters]{executing} (6 linters)} @@ -54,7 +54,7 @@ The following linters exist: \item{\code{\link{conjunct_test_linter}} (tags: best_practices, configurable, package_development, pkg_testthat, readability)} \item{\code{\link{consecutive_assertion_linter}} (tags: consistency, readability, style)} \item{\code{\link{consecutive_mutate_linter}} (tags: configurable, consistency, efficiency, readability)} -\item{\code{\link{cyclocomp_linter}} (tags: best_practices, configurable, default, readability, style)} +\item{\code{\link{cyclocomp_linter}} (tags: best_practices, configurable, readability, style)} \item{\code{\link{duplicate_argument_linter}} (tags: common_mistakes, configurable, correctness)} \item{\code{\link{empty_assignment_linter}} (tags: best_practices, readability)} \item{\code{\link{equals_na_linter}} (tags: common_mistakes, correctness, default, robustness)} diff --git a/tests/testthat/test-cyclocomp_linter.R b/tests/testthat/test-cyclocomp_linter.R index 4f2b463f70..5e14b56801 100644 --- a/tests/testthat/test-cyclocomp_linter.R +++ b/tests/testthat/test-cyclocomp_linter.R @@ -1,4 +1,6 @@ test_that("returns the correct linting", { + skip_if_not_installed("cyclocomp") + cc_linter_1 <- cyclocomp_linter(1L) cc_linter_2 <- cyclocomp_linter(2L) lint_msg <- rex::rex("Reduce the cyclomatic complexity of this function") From 46a11d27838e1a0d5936294842f2d88381007ffb Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 13 Apr 2024 22:21:48 +0200 Subject: [PATCH 02/20] update NAMESPACE --- NAMESPACE | 1 - R/lintr-package.R | 1 - 2 files changed, 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 00d9ad2e09..b31ed1b499 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -171,7 +171,6 @@ export(with_id) export(xml_nodes_to_lints) export(xp_call_name) export(yoda_test_linter) -importFrom(cyclocomp,cyclocomp) importFrom(glue,glue) importFrom(glue,glue_collapse) importFrom(rex,character_class) diff --git a/R/lintr-package.R b/R/lintr-package.R index 898db1445b..1195e61376 100644 --- a/R/lintr-package.R +++ b/R/lintr-package.R @@ -8,7 +8,6 @@ "_PACKAGE" ## lintr namespace: start -#' @importFrom cyclocomp cyclocomp #' @importFrom glue glue glue_collapse #' @importFrom rex rex regex re_matches re_substitutes character_class #' @importFrom stats na.omit From 10945c2c164e1bcf556ffcaebd3c52664ee43868 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 14 Apr 2024 07:31:42 +0200 Subject: [PATCH 03/20] error if cyclocomp is not installed --- R/cyclocomp_linter.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index d9f20882a2..0ae0604175 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -22,6 +22,12 @@ #' @seealso [linters] for a complete list of linters available in lintr. #' @export cyclocomp_linter <- function(complexity_limit = 15L) { + # nocov start + if (!requireNamespace("cyclocomp", quietly = TRUE)) { + cli::cli_abort("'cyclocomp' package needs to be installed for this linter.") + } + # nocov end + Linter(linter_level = "expression", function(source_expression) { complexity <- try_silently( cyclocomp::cyclocomp(parse(text = source_expression$content)) From 5973479a192e9842016011858d90646bdb37127d Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 14 Apr 2024 07:36:47 +0200 Subject: [PATCH 04/20] Update cyclocomp_linter.R --- R/cyclocomp_linter.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index 0ae0604175..4acb072f81 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -22,13 +22,13 @@ #' @seealso [linters] for a complete list of linters available in lintr. #' @export cyclocomp_linter <- function(complexity_limit = 15L) { - # nocov start - if (!requireNamespace("cyclocomp", quietly = TRUE)) { - cli::cli_abort("'cyclocomp' package needs to be installed for this linter.") - } - # nocov end - Linter(linter_level = "expression", function(source_expression) { + # nocov start + if (!requireNamespace("cyclocomp", quietly = TRUE)) { + cli::cli_abort("'cyclocomp' package needs to be installed for this linter.") + } + # nocov end + complexity <- try_silently( cyclocomp::cyclocomp(parse(text = source_expression$content)) ) From 108870d101cbcc59f9e3c798d7130a732523e8d7 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 14 Apr 2024 07:58:48 +0200 Subject: [PATCH 05/20] more conditional skips --- tests/testthat/test-cache.R | 2 ++ tests/testthat/test-get_source_expressions.R | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 6b0c47aa1d..03d0a1c9ae 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -434,6 +434,8 @@ test_that("it works outside of a package", { }) test_that("cache = TRUE workflow works", { + skip_if_not_installed("cyclocomp") + # Need a test structure with a safe to load .lintr pkg <- "dummy_packages/package" files <- normalizePath(list.files(pkg, recursive = TRUE, full.names = TRUE)) diff --git a/tests/testthat/test-get_source_expressions.R b/tests/testthat/test-get_source_expressions.R index dbacecacce..2acdded007 100644 --- a/tests/testthat/test-get_source_expressions.R +++ b/tests/testthat/test-get_source_expressions.R @@ -414,6 +414,8 @@ param_df$.test_name <- with(param_df, sprintf("%s on expression %d", linter, exp patrick::with_parameters_test_that( "linters pass with xml_missing() content", { + skip_if_not_installed("cyclocomp") + if (linter == "backport_linter") { # otherwise we test the trivial linter (#2339) linter <- backport_linter(r_version = "3.6.0") From cd54c31a4f3a34ac7cd426fddb89f5181065d7d2 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 14 Apr 2024 21:24:27 +0200 Subject: [PATCH 06/20] Update error message --- R/cyclocomp_linter.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index 4acb072f81..1bd7afcf4a 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -25,7 +25,10 @@ cyclocomp_linter <- function(complexity_limit = 15L) { Linter(linter_level = "expression", function(source_expression) { # nocov start if (!requireNamespace("cyclocomp", quietly = TRUE)) { - cli::cli_abort("'cyclocomp' package needs to be installed for this linter.") + cli::cli_abort(c( + "Cyclocomp complexity is computed using {.fn cyclocomp::cyclocomp}.", + i = "Please install the needed {.pkg cyclocomp} package." + )) } # nocov end From a41fae5f846932ff77fdb7f02d2a4b35a2a1095d Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 20 Apr 2024 10:27:27 +0200 Subject: [PATCH 07/20] Update NEWS.md --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 6cd4f9d724..26671e8933 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,7 @@ * `extraction_operator_linter()` is deprecated. Although switching from `$` to `[[` has some robustness benefits for package code, it can lead to non-idiomatic code in many contexts (e.g. R6 classes, Shiny applications, etc.) (#2409, @IndrajeetPatil). To enable the detection of the `$` operator for extraction through partial matching, use `options(warnPartialMatchDollar = TRUE)`. * `unnecessary_nested_if_linter()` is deprecated and subsumed into the new/more general `unnecessary_nesting_linter()`. * Drop support for posting GitHub comments from inside GitHub comment bot, Travis, Wercker, and Jenkins CI tools (spurred by #2148, @MichaelChirico). We rely on GitHub Actions for linting in CI, and don't see any active users relying on these alternatives. We welcome and encourage community contributions to get support for different CI system going again. +* `cyclocomp_linter()` is no longer part of the default linters (#2555, @IndrajeetPatil) because the tidyverse style guide doesn't contain any guidelines on meeting certain complexity requirements. New users will need to install the needed `{cyclocomp}` package and, if relevant, also install it in the CI/CD pipelines. ## Bug fixes From 6a46496417f3efaf61724dda72e0a6bd7fcb7359 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 11:06:17 +0530 Subject: [PATCH 08/20] Update NEWS.md Co-authored-by: Michael Chirico --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 26671e8933..edc95cdc33 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,7 +15,7 @@ * `extraction_operator_linter()` is deprecated. Although switching from `$` to `[[` has some robustness benefits for package code, it can lead to non-idiomatic code in many contexts (e.g. R6 classes, Shiny applications, etc.) (#2409, @IndrajeetPatil). To enable the detection of the `$` operator for extraction through partial matching, use `options(warnPartialMatchDollar = TRUE)`. * `unnecessary_nested_if_linter()` is deprecated and subsumed into the new/more general `unnecessary_nesting_linter()`. * Drop support for posting GitHub comments from inside GitHub comment bot, Travis, Wercker, and Jenkins CI tools (spurred by #2148, @MichaelChirico). We rely on GitHub Actions for linting in CI, and don't see any active users relying on these alternatives. We welcome and encourage community contributions to get support for different CI system going again. -* `cyclocomp_linter()` is no longer part of the default linters (#2555, @IndrajeetPatil) because the tidyverse style guide doesn't contain any guidelines on meeting certain complexity requirements. New users will need to install the needed `{cyclocomp}` package and, if relevant, also install it in the CI/CD pipelines. +* `cyclocomp_linter()` is no longer part of the default linters (#2555, @IndrajeetPatil) because the tidyverse style guide doesn't contain any guidelines on meeting certain complexity requirements. Note that users with `cyclocomp_linter()` in their configs may now need to install {cyclocomp} intentionally, in particular in CI/CD pipelines. ## Bug fixes From b65e0a9e517136e77de4d05b77ab650d1f91357c Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 19:17:18 +0200 Subject: [PATCH 09/20] remove unnecessary skip --- tests/testthat/test-cache.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 03d0a1c9ae..6b0c47aa1d 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -434,8 +434,6 @@ test_that("it works outside of a package", { }) test_that("cache = TRUE workflow works", { - skip_if_not_installed("cyclocomp") - # Need a test structure with a safe to load .lintr pkg <- "dummy_packages/package" files <- normalizePath(list.files(pkg, recursive = TRUE, full.names = TRUE)) From baf9512b799bc718858d908a569ead222f13571c Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 19:37:48 +0200 Subject: [PATCH 10/20] ignore rd xref note --- DESCRIPTION | 1 + tools/check.env.R | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 tools/check.env.R diff --git a/DESCRIPTION b/DESCRIPTION index fdd59d0d76..e6d33c4102 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,6 +53,7 @@ VignetteBuilder: Config/Needs/website: tidyverse/tidytemplate Config/Needs/development: pkgload, cli, testthat, patrick Config/testthat/edition: 3 +Config/rcmdcheck/ignore-inconsequential-notes: true Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 diff --git a/tools/check.env.R b/tools/check.env.R new file mode 100644 index 0000000000..da8660f1ab --- /dev/null +++ b/tools/check.env.R @@ -0,0 +1,2 @@ +# Do not check Rd cross references +_R_CHECK_RD_XREFS_=false From c62524940849975de5f8119e11545564e298b1b1 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 19:39:10 +0200 Subject: [PATCH 11/20] fix file ext --- tools/{check.env.R => check.env} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{check.env.R => check.env} (100%) diff --git a/tools/check.env.R b/tools/check.env similarity index 100% rename from tools/check.env.R rename to tools/check.env From b834c1c05d7c63be39e0546415d02a524c6804ae Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 19:58:14 +0200 Subject: [PATCH 12/20] Revert "fix file ext" This reverts commit c62524940849975de5f8119e11545564e298b1b1. --- tools/{check.env => check.env.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{check.env => check.env.R} (100%) diff --git a/tools/check.env b/tools/check.env.R similarity index 100% rename from tools/check.env rename to tools/check.env.R From 34bec9797724ffedd9080f0f5f508b2ab24d5a79 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 19:58:18 +0200 Subject: [PATCH 13/20] Revert "ignore rd xref note" This reverts commit baf9512b799bc718858d908a569ead222f13571c. --- DESCRIPTION | 1 - tools/check.env.R | 2 -- 2 files changed, 3 deletions(-) delete mode 100644 tools/check.env.R diff --git a/DESCRIPTION b/DESCRIPTION index e6d33c4102..fdd59d0d76 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,7 +53,6 @@ VignetteBuilder: Config/Needs/website: tidyverse/tidytemplate Config/Needs/development: pkgload, cli, testthat, patrick Config/testthat/edition: 3 -Config/rcmdcheck/ignore-inconsequential-notes: true Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 diff --git a/tools/check.env.R b/tools/check.env.R deleted file mode 100644 index da8660f1ab..0000000000 --- a/tools/check.env.R +++ /dev/null @@ -1,2 +0,0 @@ -# Do not check Rd cross references -_R_CHECK_RD_XREFS_=false From 075e5b42f98631693b4717937d02fad7fc071f94 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 20:29:28 +0200 Subject: [PATCH 14/20] fix Rd issue --- R/cyclocomp_linter.R | 4 ++-- man/cyclocomp_linter.Rd | 4 ++-- tests/testthat/test-get_source_expressions.R | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index 1bd7afcf4a..e8255f411c 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -1,9 +1,9 @@ #' Cyclomatic complexity linter #' -#' Check for overly complicated expressions. See [cyclocomp::cyclocomp()]. +#' Check for overly complicated expressions. See [cyclocomp()] function from `{cyclocomp}`. #' #' @param complexity_limit Maximum cyclomatic complexity, default `15`. Expressions more complex -#' than this are linted. See [cyclocomp::cyclocomp()]. +#' than this are linted. #' #' @examplesIf requireNamespace("cyclocomp", quietly = TRUE) #' # will produce lints diff --git a/man/cyclocomp_linter.Rd b/man/cyclocomp_linter.Rd index e4abbd741a..966aea115a 100644 --- a/man/cyclocomp_linter.Rd +++ b/man/cyclocomp_linter.Rd @@ -8,10 +8,10 @@ cyclocomp_linter(complexity_limit = 15L) } \arguments{ \item{complexity_limit}{Maximum cyclomatic complexity, default \code{15}. Expressions more complex -than this are linted. See \code{\link[cyclocomp:cyclocomp]{cyclocomp::cyclocomp()}}.} +than this are linted.} } \description{ -Check for overly complicated expressions. See \code{\link[cyclocomp:cyclocomp]{cyclocomp::cyclocomp()}}. +Check for overly complicated expressions. See \code{\link[=cyclocomp]{cyclocomp()}} function from \code{{cyclocomp}}. } \examples{ \dontshow{if (requireNamespace("cyclocomp", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/tests/testthat/test-get_source_expressions.R b/tests/testthat/test-get_source_expressions.R index 2acdded007..b12fb1b664 100644 --- a/tests/testthat/test-get_source_expressions.R +++ b/tests/testthat/test-get_source_expressions.R @@ -414,12 +414,13 @@ param_df$.test_name <- with(param_df, sprintf("%s on expression %d", linter, exp patrick::with_parameters_test_that( "linters pass with xml_missing() content", { - skip_if_not_installed("cyclocomp") - if (linter == "backport_linter") { # otherwise we test the trivial linter (#2339) linter <- backport_linter(r_version = "3.6.0") } else { + if (linter == "cyclocomp_linter") { + skip_if_not_installed("cyclocomp") + } linter <- eval(call(linter)) } expression <- expressions[[expression_idx]] From fd6f038db7b3de45c8ddbd32067b78d9415e34c8 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 20:37:35 +0200 Subject: [PATCH 15/20] fix rd issue again --- R/cyclocomp_linter.R | 2 +- man/cyclocomp_linter.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/cyclocomp_linter.R b/R/cyclocomp_linter.R index e8255f411c..5a64156bd1 100644 --- a/R/cyclocomp_linter.R +++ b/R/cyclocomp_linter.R @@ -1,6 +1,6 @@ #' Cyclomatic complexity linter #' -#' Check for overly complicated expressions. See [cyclocomp()] function from `{cyclocomp}`. +#' Check for overly complicated expressions. See `cyclocomp()` function from `{cyclocomp}`. #' #' @param complexity_limit Maximum cyclomatic complexity, default `15`. Expressions more complex #' than this are linted. diff --git a/man/cyclocomp_linter.Rd b/man/cyclocomp_linter.Rd index 966aea115a..93d42f905a 100644 --- a/man/cyclocomp_linter.Rd +++ b/man/cyclocomp_linter.Rd @@ -11,7 +11,7 @@ cyclocomp_linter(complexity_limit = 15L) than this are linted.} } \description{ -Check for overly complicated expressions. See \code{\link[=cyclocomp]{cyclocomp()}} function from \code{{cyclocomp}}. +Check for overly complicated expressions. See \code{cyclocomp()} function from \code{{cyclocomp}}. } \examples{ \dontshow{if (requireNamespace("cyclocomp", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} From 34f7f21f6251f72891494e155c1408f146cd0fe5 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 22:02:55 +0200 Subject: [PATCH 16/20] Update lint.yaml --- .github/workflows/lint.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 6ab847c84c..32b3f16ba4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,6 +21,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: | + any::cyclocomp r-lib/lintr local::. needs: lint From 1a07a08c3b223f5918b46a9b4f3c455cf6e4bcf6 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 22:23:28 +0200 Subject: [PATCH 17/20] does clearing cache first help? --- tests/testthat/test-cache.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 6b0c47aa1d..e563f29fac 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -434,6 +434,8 @@ test_that("it works outside of a package", { }) test_that("cache = TRUE workflow works", { + clear_cache() + # Need a test structure with a safe to load .lintr pkg <- "dummy_packages/package" files <- normalizePath(list.files(pkg, recursive = TRUE, full.names = TRUE)) From afbe5e6c3d65331e53f4cbbc8e3a7866b8e3a923 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 5 May 2024 22:30:14 +0200 Subject: [PATCH 18/20] Revert "does clearing cache first help?" This reverts commit 1a07a08c3b223f5918b46a9b4f3c455cf6e4bcf6. --- tests/testthat/test-cache.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index e563f29fac..6b0c47aa1d 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -434,8 +434,6 @@ test_that("it works outside of a package", { }) test_that("cache = TRUE workflow works", { - clear_cache() - # Need a test structure with a safe to load .lintr pkg <- "dummy_packages/package" files <- normalizePath(list.files(pkg, recursive = TRUE, full.names = TRUE)) From fa2280e3e3c20d42d82051e1e34c05a76206e216 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 5 May 2024 22:24:41 -0700 Subject: [PATCH 19/20] fix broken test --- tests/testthat/test-cache.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 6b0c47aa1d..62a0ed32c6 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -435,15 +435,16 @@ test_that("it works outside of a package", { test_that("cache = TRUE workflow works", { # Need a test structure with a safe to load .lintr - pkg <- "dummy_packages/package" - files <- normalizePath(list.files(pkg, recursive = TRUE, full.names = TRUE)) + withr::local_dir(file.path("dummy_packages", "package")) + withr::local_options(lintr.linter_file = "lintr_test_config") + files <- normalizePath(list.files(recursive = TRUE, full.names = TRUE)) # Manually clear cache (that function is exported) for (f in files) { clear_cache(file = f) } - l1 <- lint_package(pkg, cache = TRUE) - l2 <- lint_package(pkg, cache = TRUE) + l1 <- lint_package(cache = TRUE) + l2 <- lint_package(cache = TRUE) expect_identical(l1, l2) }) From 2d672dad924aac8879fd5c75a64bbde903ad70ac Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 7 May 2024 07:13:54 +0200 Subject: [PATCH 20/20] remove cyclocomp from default linter tests --- tests/testthat/default_linter_testcode.R | 1 - tests/testthat/dummy_projects/project/default_linter_testcode.R | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/testthat/default_linter_testcode.R b/tests/testthat/default_linter_testcode.R index 1f9f060d6c..1cadc18cc3 100644 --- a/tests/testthat/default_linter_testcode.R +++ b/tests/testthat/default_linter_testcode.R @@ -15,7 +15,6 @@ g <- function(x) { # commented_code # some <- commented("out code") -# cyclocomp # equals_na # brace_linter # indentation diff --git a/tests/testthat/dummy_projects/project/default_linter_testcode.R b/tests/testthat/dummy_projects/project/default_linter_testcode.R index ba87313b30..3098b0b025 100644 --- a/tests/testthat/dummy_projects/project/default_linter_testcode.R +++ b/tests/testthat/dummy_projects/project/default_linter_testcode.R @@ -10,7 +10,6 @@ f = function (x,y = 1){} # commented_code # some <- commented("out code") -# cyclocomp # equals_na # infix_spaces # line_length