eslint/rules/complexity
Complexity: Size and complexity limits: lines, statements, nesting, cognitive complexity. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.
9 rules, 3 on. Source: lint/eslint/rules/complexity.mjs.
| Rule | Setting | Files | What it checks | Why |
|---|---|---|---|---|
complexity | off | JS + TS | Enforce a maximum cyclomatic complexity allowed in a program | Off: replaced by sonarjs/cognitive-complexity, like SonarQube. |
max-depth | off | JS + TS | Enforce a maximum depth that blocks can be nested | Off: replaced by sonarjs/nested-control-flow, like SonarQube. |
max-lines | off | JS + TS | Enforce a maximum number of lines per file | Off: replaced by sonarjs/max-lines, like SonarQube. |
max-statements | off | JS + TS | Enforce a maximum number of statements allowed in function blocks | Off: no SonarQube equivalent. |
sonarjs/max-lines | warn, {"maximum":200} | JS + TS | Files should not have too many lines of code | Custom: outside Sonar way; replaces the core max-lines, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass. |
sonarjs/nested-control-flow | warn | JS + TS | Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply | Custom: outside Sonar way; replaces the core max-depth, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass. |
sonarjs/expression-complexity | off | JS + TS | Expressions should not be too complex | Off: not in the Sonar way profile of SonarQube. |
sonarjs/cognitive-complexity | warn | JS + TS | Cognitive Complexity of functions should not be too high | Sonar way; replaces the core complexity, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass. |
sonarjs/cyclomatic-complexity | off | JS + TS | Cyclomatic Complexity of functions should not be too high | Off: not in the Sonar way profile of SonarQube. |