Rules
In the Rules tab you can configure the rules that are taken into account when the static analysis is performed. The rules are displayed as a tree structure in the project properties. Some rules are arranged below organizational nodes.
The rules alert you to possibly inadvertent and erroneous implementations so that you can optimize these program parts at an early stage.
Up to three configuration options are available for the rules:
1. Configuration of the control activity
Individual rules can be enabled or disabled via the checkbox for the respective row. Ticking the checkbox for a subnode affects all entries below this node. Ticking the checkbox for the top node affects all list entries. The entries below a node can be collapsed or expanded by clicking on the minus or plus sign to the left of the node name.
The number in brackets after each rule, for example "Unreachable code (1)", is the rule number that is issued if the rule is not observed, e.g. "SA0001".
The following three settings are available, which can be accessed by repeated clicking on the checkbox:
: The rule is not checked.
: A rule violation results in an error being reported in the message window.
: A rule violation results in a warning being reported in the message window.
2. Configuration of the precompile behavior
Most Static Analysis rules can already be checked during precompilation. You can use the following options to configure whether you want the result of this check to be displayed as a precompile message in the message window.
- General option: "Enable notification of precompile messages in general"
- Default: disabled
- The default value of the option means that starting with TwinCAT 3.1.4026.20 no precompile messages of the Static Analysis rules are displayed in the message window by default.
- If you want to receive precompile messages from the rules, enable the option.
- Rule-specific option: "Precompile"
- In addition to the general enabling of precompile messages, you can set for each rule whether it should be output as a precompile message.
- This option is only available for the rules that can be checked during precompilation. A list of these rules can be found at Precompile/QuickFix.
The two options mentioned above allow you to configure whether you want to receive precompile messages at all. If so, you can also specify in detail which rules this should apply to.
Consequently, precompile messages are only issued for a specific rule if the following conditions are met:
- Option "Enable notification of precompile messages in general" = enabled
- The rule check is enabled (as an error or warning)
- Option "Precompile" of the rule = enabled
3. Configuration of control parameters/limits
Some rules can be parameterized, allowing limits to be set individually, for example. You can configure the parameters to be taken into account in the respective check by double-clicking on the row of the corresponding rule in the rule configuration (PLC project properties > "Static Analysis" category > "Rules" tab). You can set the control parameters in the dialog that opens. The currently configured parameters are displayed in the "Limits" column of the control configuration.
An overview of the parameterizable rules can be found on the following page: Rules - overview and description
More Information:
Syntax of rule violations in the message window
Each rule has a unique number (shown in parentheses after the rule in the rule configuration view). If a rule violation is detected during the static analysis, the number together with an error or warning description is issued in the message window, based on the following syntax. The abbreviation "SA" stands for "Static Analysis".
Syntax: "SA<rule number>: <rule description>"
Sample for rule number 33 (unused variables): "SA0033: Not used: variable 'bSample'"
Temporary disabling of rules
Rules that are enabled in this dialog can be temporarily disabled in the project via a pragma. For further information please refer to Pragmas and attributes.
Overview and description of the rules
An overview of the rules and a detailed description of the rules can be found at Rules - overview and description.