code-complexity
July 2, 2025 ยท View on GitHub
Description
Function has cyclomatic complexity "current" but allowed no more than configured max complexity.
Options
This rule accepts an array of options:
| Index | Description | Default Value |
|---|---|---|
| 0 | Rule severity. Must be one of "error", "warn", "off". | warn |
| 1 | Function cyclomatic complexity reached. | 7 |
Example Config
{
"rules": {
"code-complexity": [
"warn",
7
]
}
}
Examples
๐ Examples of correct code for this rule
Low code complexity
if (a > b) {
if (b > c) {
if (c > d) {
}
}
}
for (i = 0; i < b; i += 1) { }
do { d++; } while (b > c);
while (d > e) { }
๐ Examples of incorrect code for this rule
High code complexity
if (a > b) {
if (b > c) {
if (c > d) {
if (d > e) {
} else {
}
}
}
}
for (i = 0; i < b; i += 1) { }
do { d++; } while (b > c);
while (d > e) { }
Version
This rule was introduced in Solhint 5.0.4