Skip to contents

Check for overly complicated expressions. See cyclocomp::cyclocomp().

Usage

cyclocomp_linter(complexity_limit = 15L)

Arguments

complexity_limit

Maximum cyclomatic complexity, default 15. Expressions more complex than this are linted. See cyclocomp::cyclocomp().

See also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "if (TRUE) 1 else 2",
  linters = cyclocomp_linter(complexity_limit = 1L)
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[cyclocomp_linter] Functions should have cyclomatic complexity of less than 1, this has 2.

# okay
lint(
  text = "if (TRUE) 1 else 2",
  linters = cyclocomp_linter(complexity_limit = 2L)
)