The Add-on Quality Check & CtrlPPCheck by SloopTools deals with Code Quality. Overall, code quality is important to software quality. And quality influences how safe and reliable your codebase is. High quality is of critical importance to many development teams today. This is particularly important for those who develop safety-critical applications, e.g. SCADA or HMI.
The Add-on is divided into two major parts:
The aim of the SloopTools Quality Checks is to improve the code quality of WinCC OA projects and to offer a comprehensive service. The seamless integration into the development environment of WinCC OA (GEDI) was very important to us. The integration into the GEDI was carried out in the following places:
Drop-Down menu in the GEDI menu bar - Dock-Module for the GEDI with results
Script check via button in the script editor
With the Quality Checks, SloopTools now provides the Quality Gate (quality control of add-ons), which is available to the providers in the SloopTools Store. Simple and clearly presented to give users a quick and easy way to test the code.
The individual checks are to be used as follows:
After a check has taken place (the duration varies depending on the script length or file number), the results are listed in the respective tab of the dock module or can be found via the drop-down menu "Open Results". The results are listed in a tree clearly for the entire project. The tree represents the folder structure of the tested project.
These checks can be used immediately with the free Add-on for each project.
More details on the individual checks in the chapter Quality Gate
To perform these checks, the software python must be installed. You need version 3.6 or higher.
To go one step further in static code analysis, SloopTools has modified the well-known cppCheck to "learn" the WinCC OA scripting language CTRL & CTRL ++. Now you can use cppCheck to perform a static code analysis in the WinCC OA development environment.
The CtrlPPCheck is to be used as follows:
The following 3 levels of licensing are available for the SloopTools Quality Check:
It is also possible to start the CtrlPPCheck via command line, eg. integrate this check into its build environment. More about this under CtrlPPCheck - command line.
The possible severities for messages are:
Severity | Description |
---|---|
error | used when bugs are found |
warning | suggestions about defensive programming to prevent bugs |
style | stylistic issues related to code cleanup (unused functions redundant code, constness, and such) |
performance | Suggestions for making the code faster. These suggestions are only based on common knowledge. It is not certain you'll get any measurable difference in speed by fixing these messages. |
portability | portability warnings. 64-bit portability. The code might work differently on different compilers. etc. |
information | Configuration problems. The recommendation is to only enable these during configuration. |
If the reported problem is not a problem in this constellation for some reason, the message can be suppressed. Activate this functionality via settings - Inline Suppression.
You can specify that the inline suppression only applies to a specific symbol:
// ctrlppcheck-suppress undefinedVariable
unknownVar = 3;
You can describe the reason for the suppression with a commentary. For this a semicolon (;) or two slashes (//) can be used for the separation.
// ctrlppcheck-suppress undefinedVariable ; some comment
// ctrlppcheck-suppress undefinedVariable // some comment
SloopTools has planned further updates for the CtrlPPCheck. The following features or enhancements are planned for the future (see Changelog):
int functionA()
{
if (something)
{ //do something
return "something"; // Wrong return type int
}
else
{ //do something
return 1; // Right
}
}
float st;
int i;
string rs = functionB(f,i) // Wrong return value type for rs (Casting not 100%)
int functionB(float f, int i)
{
//do something
}
string st;
int i;
int ri = functionB(st,i) // Wrong parameter type st
int functionB(float f, int i)
{
//do something
}