Login
caseStatemets rule
Login

The rule to check do case statements in the code don't contain some expressions. Checked things:

The syntax in a configuration file is:

[ruleType] ?not? caseStatements [checkType] [amount]

Disabling the rule

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

{.ruleOff: "caseStatements".}
case a
of 1:
  echo a

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

{.ruleOn: "caseStatements".}
case a
of 1:
  echo a

Examples

  1. Check if all case statements have at least 4 branches:

    check caseStatements min 4