Command 'Run static analysis'

Symbol: Command 'Run static analysis' 1:

Function: The command starts the static code analysis for the currently active PLC project and outputs the results in the message window.

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

 

During execution of the static analysis, compliance with the coding rules, naming conventions and forbidden symbols is checked. 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 issues the result of the static analysis, i.e. messages relating to rule violations, in the message window. 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 whether the violation of a coding rule should appear as an error or a warning in the message window (see: Rules).

See also: Syntax in the message window

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 described in the following table.

Differences

Command 'Run static analysis'

Command 'Run static analysis [Check all objects]'

Scope

The objects used in the PLC project are checked. Objects that are not used are not checked with this command.

The scope of this command thus corresponds to the build commands Build Project/Solution or Rebuild Project/Solution respectively.

If you also wish to have the unused objects checked by the static analysis, which is useful, for example, when processing library projects, you can use the command Run static analysis [check all objects].

All objects in the project tree of the PLC project are checked.

This is primarily useful when creating libraries or when processing library projects.

The scope of this command thus corresponds to the build command Check all objects.

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 option Perform static analysis automatically is enabled, TwinCAT performs the static analysis after each successful code generation (with the command Build project, for example).

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