SA0178: Cognitive complexity

Function

The check determines whether a defined limit of cognitive complexity is exceeded in a function block.

You can configure the parameter that is taken into account in the check by double-clicking on the row for rule 178 in the rule configuration (PLC Project Properties > category "Static Analysis" > "Rules" tab > Rule 178). You can make the following settings in the dialog that appears:

  • Complexity limit (default value: 20)

Reason

This is about checking individual programming guidelines. Some programming guidelines stipulate a maximum value for the cognitive complexity of function blocks. Excessive cognitive complexity makes the code difficult to read and maintain.

Importance

Medium

SA0178: Cognitive complexity 1:

Corresponding metric available

The following metric is available for calculating cognitive complexity as part of the metrics table:

Cognitive complexity