Command 'Run static analysis'

Symbol: Command 'Run static analysis' 1:

Function: This command initiates static code analysis for the currently active PLC project and displays the results in the error list.

Call: Menu Build or context menu of the PLC project object

 

During execution of the static analysis, the system checks for compliance with coding rules, naming conventions and prohibited symbols. This command can be used to trigger a static analysis manually (explicit execution), or the analysis can be performed automatically during code generation (implicit execution, see below for more information).

TwinCAT displays the results of the static analysis – i.e. messages regarding rule violations – in the error list. The rules, naming conventions and forbidden symbols to be taken into account in the static analysis can be configured in the PLC project properties. You can also define under Rules whether the violation of a coding rule should appear as an error or a warning Error list.

Command 'Run static analysis' 2:

Please note that the selected PLC project is created before this command is executed. Checking via the static analysis is only started if the code generation was successful, i.e. if the compiler did not detect any compilation errors.

 

Please also note the Command 'Run static analysis [Check all objects]' and the differences between the two commands, which are described in the following table.

Differences

'Run static analysis' command

'Run static analysis [Check all objects]' command

Scope of application/mode of operation

Objects used:

The activated rules are applied to the objects that are used in the PLC project.

Unused objects:

Unused objects are not checked with this command.

Objects used:

The activated rules are applied to the objects that are used in the PLC project.

Unused objects:

The rules that are activated and that can be checked in the precompile are applied to the unused objects.

See also: Precompile

Note

If you also wish to have the unused objects checked by the static analysis, you can use the 'Run static analysis [check all objects]' command.

The command is primarily useful when creating libraries or when processing library projects.

Execution options for the command

Static analysis can be performed either explicitly using the command or implicitly.

Implicit execution of the static analysis during each code generation can be enabled or disabled in the PLC project properties (Settings tab). If the Perform static analysis automatically option is enabled, TwinCAT performs the static analysis after each successful code generation (with the Build project command, for example).

The command can also be called up via the Automation Interface. See also: Automation Interface support

The "Check all objects" variant cannot be executed implicitly. It can only be executed explicitly via the command.

The command can also be called up via the Automation Interface. See also: Automation Interface support