Login
complexity rule
Login

Count the complexity of the selected code. Possible complexity formulas: cyclomatic.

The syntax in a configuration file is:

[ruleType] ?not? complexity [checkType] [codeType] [value]

Disabling the rule

It is possible to disable the rule for a selected part of the checked code by using pragma ruleOff: "complexity" in the code before it. For example, if the rule should be disabled for the procedure main declaration, the full declaration of it should be:

 {.ruleOff: "complexity".}
 proc main() =
   discard

To enable the rule again, the pragma ruleOn: "complexity" should be added in the code before it. For example, if the rule should be re-enabled for if statement, the full declaration should be:

 {.ruleOn: "complexity".}
 if a == 1:
   echo a

Examples

  1. Check if all code blocks are maximum high risk code in cyclomatic complexity:

    check complexity cyclomatic all 50

  2. Search for procedures declaration which cyclomatic complexity is below medium risk:

    search not complexity cyclomatic routines 20