Quality Check & CtrlPPCheck


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:

  • Quality Check

    • The SloopTools Quality Gate within the GEDI
    • Following checks, among many others, are included:
      • Mc Cabe Complexity
      • Code lines per script / lib
      • Code lines per function
      • Number of functions per script / lib
      • Number of functions per panel
      • Number of parameters per function
      • Number of properties per panel
      • Number of files per folder
      • and other ...
    • Furthermore, the integrity of the project is checked with the following checks:
      • Pictures used in the project
      • Overloaded files from the version (reason: maintenance purposes)
  • ctrlPPCheck

    • Static code analysis ala cppCheck for WinCC OA CTRL in the GEDI
    • Included are, among many others, these checks:
      • Undefined variables
      • Unused variables
      • Unused functions
      • Dead code
      • Comparison is always true / false
      • Return value of a specific function is not used
        • e.g. return from dpExists(), ...
      • and other ...

Video Tutorial

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

Integration GEDI Drop-Down menu in the GEDI menu bar - Dock-Module for the GEDI with results

Integration GEDI Script check via button in the script editor

Quality Check

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:

  • Check the entire project
    • Drop-Down menu - respective entry
    • Dock-Module - respective start button
  • Check per script
    • CtrlPPCheck button in the script editor

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

Prerequisite

To perform these checks, the software python must be installed. You need version 3.6 or higher.

ctrlPPCheck

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:

  • Check the entire project
    • Drop-down menu - CtrlPPCheck
    • Dock-Module - CtrlPPCheck
  • Check per script
    • CtrlPPCheck button in the script editor

Licensing

The following 3 levels of licensing are available for the SloopTools Quality Check:

  • FREE version
    • CtrlPPCheck for script files and recursive project check are included. Limitations: Max. 1 error per error ID will be shown. For full functionality, buy the CtrlPPCheck feature in the SloopTools Store
  • DEMO version
    • CtrlPPCheck for script files and recursive project check are included. Limitations: Max. 1 error per error ID will be shown. For full functionality, buy the CtrlPPCheck feature in the SloopTools Store
  • FULL version
    • Script files with unlimited lines and an unlimited amount of files for recursive project check are included. All errors will be shown.
    • This version requires a FREE license with the additional feature "CtrlPPCheck" from the SloopTools Store. This must be purchased and activated via the installer.

Command Line

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.

Severities

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.

Suppression of Messages

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

Roadmap

SloopTools has planned further updates for the CtrlPPCheck. The following features or enhancements are planned for the future (see Changelog):

  • WinCC OA CTRL Library Check - All missing CTRL functions will be configured to check the number of arguments and return value (Available since version 1.0.2)
  • Complete panel check - Including Ctrl + E and Scope-Lib (Available since version 1.1.0)
  • Linux support - on request (Available since version 1.1.0)
  • Single Site License - (Available since version 1.1.0)
  • Borders for quality control customizable - e.g. Lines per function, number of files in the directory, ...
  • Check your coding guidelines - e.g. Functions always begin with the prefix "xy_"
  • Own libraries check - Be able to configure and check arguments and return values ​​from own libraries
  • Create a report - HTML or PDF report for your quality assurance
  • Complete project check also for panels
  • Also check all subprojects - Not just the local project
  • Check if there is an overload from the local project to a specific subproject - Compare in more detail
  • Check specific files or directories from the file tree - e.g. all scripts under class (right mouse on file tree)
  • CtrlPPCheck for other IDEs - e.g. Visual Studio, Eclipse to check WinCC OA code there as well
  • Check return values ​​of functions with return - Examples:
int functionA()
{
  if (something)
  {  //do something
  return "something"; // Wrong return type int
  }
  else
  {  //do something
  return 1; // Right
  }
}
  • Check return values of functions with assignment - Example:
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
}
  • Check call of functions with parameters - Example:

string st;
int i;

int ri = functionB(st,i) // Wrong parameter type st

int functionB(float f, int i)
{
  //do something
}

Limitations

Software Limitations

  • WinCC OA 3.15 and 3.16
  • Linux support
    • Currently on request

Check Limitations

  • WinCC OA CTRL Library Check is not complete
    • Not all CTRL functions have been completely configured yet
  • Undefined variables are not found in function calls
  • CtrlPPCheck notes Libs defined functions as "not used"
  • Checks only run on unencrypted files
  • Complete project check for CtrlPPCheck only for scripts / libs
  • Panel scripts can only be checked individually
    • Ctrl + E does not work and ScopeLib is not included
  • Checks in GEDI only work with event connection
  • All results from CtrlPPCheck are shown as errors in the overview
  • No own (custom) cfg files usable for the GEDI integration
  • Return values of functions with return are not checked
  • Return values of functions with assignment are not checked
  • Calling functions with parameters is not checked

License Limitations

  • Number of errors reported dependend on the license
  • '#uses' will only be considered if there is a CtrlPPCheck license

Open Source Information

The following tools are included with the Add-on:

results matching ""

    No results matching ""