Already when programming in CODESYS, CODESYS Static Analysis helps to write more readable code and to detect contradictory or unsupported settings. In particular, potential sources of error can be identified, such as test code or pointers that have not been checked for 0 before dereferencing. With specific checks, you can make sure that the code is portable. Example: The analysis should report the use of language resources for object orientation because the code is to run on platforms that do not support object orientation.
The analysis checks the source code of the CODESYS project and reports any deviations from certain coding rules, naming conventions, or permitted keywords and identifiers. CODESYS Static Analysis is based on the rule set defined in the PLCopen Coding Guidelines and extends it with additional test options.
You can display the detected deviations as errors or warnings in the message view before the project is downloaded to the target system. For errors that are reported by Static Analysis based on precompile information, there is support for an immediate error handling ("Quickfix").
You activate Static Analysis either explicitly by clicking “Build Run Static Analysis”, or you let it execute automatically at each code generation. You activate the automatic execution in the “Static Analysis” dialog of the projects settings. In this dialog, you also configure what is to be checked in detail. You can use pragma statements to exclude individual parts of the code from the check.
To evaluate the code quality, you can also display selected metrics that CODESYS Static Analysis detects in your code in a separate view. An example of this is the McCabe metric, which measures the cyclomatic complexity and indicates the number of execution paths that can be processed during code execution.




NOTICE

The analysis is performed only for the code of the applications in the current project. Libraries are not taken into consideration.
The CODESYS development system contains a light version of Static Analysis that is extended by CODESYS Static Analysis.
Application example
Application example
The Pro Static Analysis tool can be used to check the source code during programming or for debugging purposes in order to identify possible weaknesses of the code. Usage and benefits of the Pro Static Analysis tool are described in the application example ⮫ Pro Static Analysis tool.