Check for overly complicated expressions. See cyclocomp()
function from {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)
)
#> <text>:1:1: style: [cyclocomp_linter] Reduce the cyclomatic complexity of this function from 2 to at most 1.
#> if (TRUE) 1 else 2
#> ^
# okay
lint(
text = "if (TRUE) 1 else 2",
linters = cyclocomp_linter(complexity_limit = 2L)
)
#> ℹ No lints found.