Login
ifStatemets rule
Login

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

The syntax in a configuration file is:

[ruleType] ?not? ifStatements [checkType] [amount]

Disabling the rule

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

{.ruleOff: "ifStatements".}
if a == 1:
  echo a

To enable the rule again, the pragma ruleOn: "ifStatements" 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: "ifStatements".}
if a == 1:
  echo a

Examples

  1. Check if all if and when statements are correct:

    check ifStatements all

  2. Remove all empty if and when statements:

    fix ifStatements empty

  3. Check if all if and when statements have at least 3 branches:

    check ifStatements min 3