Skip to content

Commit

Permalink
Make cyclocomp_linter() optional
Browse files Browse the repository at this point in the history
closes #2554
  • Loading branch information
IndrajeetPatil committed Apr 13, 2024
1 parent d86738f commit ad71db5
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Depends:
Imports:
backports (>= 1.1.7),
codetools,
cyclocomp,
digest,
glue,
knitr,
Expand All @@ -37,6 +36,7 @@ Imports:
Suggests:
bookdown,
cli,
cyclocomp,
jsonlite,
patrick (>= 0.2.0),
rlang,
Expand Down
4 changes: 2 additions & 2 deletions R/cyclocomp_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion inst/lintr/linters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions man/cyclocomp_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/default_linters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/linters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/testthat/test-cyclocomp_linter.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit ad71db5

Please sign in to comment.