From 967998b3a058754d4a6856d60bbd60fc02b98ab8 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Fri, 5 May 2023 12:50:46 +0200 Subject: [PATCH 01/22] eliminate: Too many arguments for function call QgApp. max: 1, given: 2 --- .../scripts/libs/classes/QualityGates/QgApp.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgApp.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgApp.ctl index aa03161..815888c 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgApp.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgApp.ctl @@ -55,7 +55,7 @@ class QgApp return app; } - QgApp app = QgApp(items[3], items[2]); + QgApp app = QgApp(items[3]); return app; } From ed6f087ceb20ea9c59382da9e70dc35687fd13ee Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sat, 6 May 2023 13:44:08 +0200 Subject: [PATCH 02/22] clean up 1 --- .../msg/de_AT.utf8/QgBase.cat | 7 +- .../de_AT.utf8/QgStaticCheck_StaticDir.cat | 2 +- .../msg/en_US.utf8/QgBase.cat | 7 +- .../general/Settings.pnl | 4 +- .../StaticTests/QgPanelsCheck.ctl | 4 +- .../StaticTests/QgScriptsCheck.ctl | 55 +++-- .../libs/classes/ErrorHdl/OaLogger.ctl | 113 ++++++++++ .../scripts/libs/classes/FileSys/QgDir.ctl | 7 + .../scripts/libs/classes/FileSys/QgFile.ctl | 7 + .../libs/classes/QualityGates/QgBase.ctl | 56 +++-- .../libs/classes/QualityGates/QgSettings.ctl | 7 +- .../QgStaticCheck/CtrlCode/ScriptsDir.ctl | 2 +- .../QgStaticCheck/Panels/PanelCheck.ctl | 29 +-- .../Panels/PanelFile/PanelFile.ctl | 107 +++++---- .../QgStaticCheck/Panels/PanelsDir.ctl | 2 +- .../QgStaticCheck/Pictures/PicturesDir.ctl | 4 +- .../QgStaticCheck/StaticCodeDir.ctl | 15 +- .../QualityGates/QgStaticCheck/StaticDir.ctl | 14 +- .../QgSyntaxCheck/QgSyntaxCheck.ctl | 2 +- .../classes/QualityGates/QgVersionResult.ctl | 1 + .../scripts/libs/classes/WinCCOA_Json.ctl | 183 --------------- .../scripts/libs/classes/WinCCOA_Logger.ctl | 209 ------------------ 22 files changed, 330 insertions(+), 507 deletions(-) create mode 100644 WinCCOA_QualityChecks/scripts/libs/classes/ErrorHdl/OaLogger.ctl delete mode 100644 WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Json.ctl delete mode 100644 WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Logger.ctl diff --git a/WinCCOA_QualityChecks/msg/de_AT.utf8/QgBase.cat b/WinCCOA_QualityChecks/msg/de_AT.utf8/QgBase.cat index 36df3e4..5291124 100644 --- a/WinCCOA_QualityChecks/msg/de_AT.utf8/QgBase.cat +++ b/WinCCOA_QualityChecks/msg/de_AT.utf8/QgBase.cat @@ -1,3 +1,8 @@ -00001,QualityGates does not run succesfully !!! +00001,QualityGates does not run successfully !!! 00010,Assertion return error: $1 00011,Assertion works: $1 +00020,The function $1 is not implemented. +00021,Start quality gate $1. +00022,Calculate sources for quality gate $1. +00023,Validate results for quality gate $1. +00024,Quality gate $1 done. It takes to mee $2 [s.ms]. diff --git a/WinCCOA_QualityChecks/msg/de_AT.utf8/QgStaticCheck_StaticDir.cat b/WinCCOA_QualityChecks/msg/de_AT.utf8/QgStaticCheck_StaticDir.cat index 532c36b..a6451d2 100644 --- a/WinCCOA_QualityChecks/msg/de_AT.utf8/QgStaticCheck_StaticDir.cat +++ b/WinCCOA_QualityChecks/msg/de_AT.utf8/QgStaticCheck_StaticDir.cat @@ -1,7 +1,7 @@ assert.dir.isCalculated,Is calculated reason.dir.isCalculated,Sorry, the directory '($dir.name)' can't be calculated. assert.dir.hasFilesRecursive,Count of files recursive -reason.dir.hasFilesRecursive,Directory '$dir.name' or sub directories doesn´t contain any files. Delete all empty dirs. +reason.dir.hasFilesRecursive,Directory '$dir.name' or sub directories doesn´t contain any files. Delete all empty dirs. assert.dir.isEmpty,Is empty reason.dir.isEmpty,Directory '$dir.name' doesn´t contains any files or sub directories. assert.dir.subDirCount,Count of sub directories diff --git a/WinCCOA_QualityChecks/msg/en_US.utf8/QgBase.cat b/WinCCOA_QualityChecks/msg/en_US.utf8/QgBase.cat index 36df3e4..5291124 100644 --- a/WinCCOA_QualityChecks/msg/en_US.utf8/QgBase.cat +++ b/WinCCOA_QualityChecks/msg/en_US.utf8/QgBase.cat @@ -1,3 +1,8 @@ -00001,QualityGates does not run succesfully !!! +00001,QualityGates does not run successfully !!! 00010,Assertion return error: $1 00011,Assertion works: $1 +00020,The function $1 is not implemented. +00021,Start quality gate $1. +00022,Calculate sources for quality gate $1. +00023,Validate results for quality gate $1. +00024,Quality gate $1 done. It takes to mee $2 [s.ms]. diff --git a/WinCCOA_QualityChecks/panels/WinCCOA_QualityChecks/general/Settings.pnl b/WinCCOA_QualityChecks/panels/WinCCOA_QualityChecks/general/Settings.pnl index d481b17..3685e91 100644 --- a/WinCCOA_QualityChecks/panels/WinCCOA_QualityChecks/general/Settings.pnl +++ b/WinCCOA_QualityChecks/panels/WinCCOA_QualityChecks/general/Settings.pnl @@ -606,7 +606,7 @@ T 2 LANG:10001 4 Save LANG:10000 9 Speichern -"#uses \"classes/WinCCOA_Json\" +"#uses \"classes/json/JsonFile\" main(mapping event) { @@ -631,7 +631,7 @@ void saveChanges() string file_name = setting[\"changed\"] + \".json\"; mappingRemove(setting, \"changed\"); - Sl_Jsonfile jsonFile = Sl_Jsonfile(path + file_name, true); + JsonFile jsonFile = JsonFile(path + file_name, true); jsonFile.write(setting); } } diff --git a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPanelsCheck.ctl b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPanelsCheck.ctl index 9acd156..ee3c120 100644 --- a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPanelsCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPanelsCheck.ctl @@ -38,7 +38,9 @@ class QgStaticPanelCheck : QgBase if ( QgBase::setUp() ) return -1; - throwError(makeError("", PRIO_INFO, ERR_CONTROL, 0, Qg::getId() + " will check " + this.checkedPath + PANELS_REL_PATH)); + + PanelCheck::setSourceDirPath(this.checkedPath); + PanelFile::setSourceDirPath(this.checkedPath); _panels.setDir(this.checkedPath + PANELS_REL_PATH); if ( !_panels.exists() ) diff --git a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl index aa680bb..1531d62 100644 --- a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl @@ -7,24 +7,29 @@ // SPDX-License-Identifier: GPL-3.0-only // -//-------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- // used libraries (#uses) +#uses "classes/ErrorHdl/OaLogger" #uses "classes/QualityGates/QgStaticCheck/CtrlCode/ScriptsDir" #uses "classes/QualityGates/Qg" #uses "classes/QualityGates/QgBase" -//-------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- // declare variables and constans -//-------------------------------------------------------------------------------- -/*! - @brief Static code checker for ctrl scripts / libs +//----------------------------------------------------------------------------- +/** Static code checker for ctrl WinCC OA scripts / libs @author lschopp */ class QgStaticCheck_Scripts : QgBase { +//----------------------------------------------------------------------------- +//@public members +//----------------------------------------------------------------------------- public string checkedPath = PROJ_PATH; + + //--------------------------------------------------------------------------- public int setUp() { if ( QgBase::setUp() ) @@ -32,26 +37,25 @@ class QgStaticCheck_Scripts : QgBase throwError(makeError("", PRIO_SEVERE, ERR_CONTROL, 0, "QgBase::setUp fails")); return -1; } - + if ( Qg::getId() == "QgStaticCheck_Scripts" ) { - throwError(makeError("", PRIO_INFO, ERR_CONTROL, 0, Qg::getId() + " will check " + this.checkedPath + SCRIPTS_REL_PATH)); _scriptsData.setDir(this.checkedPath + SCRIPTS_REL_PATH); _scriptsData.setType(ScriptsDataType::scripts); } else if ( Qg::getId() == "QgStaticCheck_Libs" ) { - throwError(makeError("", PRIO_INFO, ERR_CONTROL, 0, Qg::getId() + " will check " + this.checkedPath + LIBS_REL_PATH)); _scriptsData.setDir(this.checkedPath + LIBS_REL_PATH); _scriptsData.setType(ScriptsDataType::libs); } if ( !_scriptsData.exists() ) setMinValidScore(Qg::getId(), "assert.missingScripts", "reason.missingScripts"); - + return 0; } + //--------------------------------------------------------------------------- public int calculate() { if ( _scriptsData.exists() ) @@ -59,33 +63,43 @@ class QgStaticCheck_Scripts : QgBase else return 0; } - + + //--------------------------------------------------------------------------- public int validate() { - if ( (Qg::getId() == "QgStaticCheck_Scripts") && (_scriptsData.getCountOfFilesRecursive() <= 0) && + if ( (Qg::getId() == "QgStaticCheck_Scripts") && (_scriptsData.getCountOfFilesRecursive() <= 0) && isdir(this.checkedPath + LIBS_REL_PATH) && (_scriptsData.getCountOfSubDirs() <= 0) ) { // there are no scripts. Libs only and libs are checked in QgStaticCheck_Libs setMinValidScore("QgStaticCheck_Scripts", "assert.missingScripts", "reason.missingScripts"); return 0; } - + return _scriptsData.validate(); } - + //--------------------------------------------------------------------------- public int tearDown() { _result = _scriptsData.result; return QgBase::tearDown(); } - + +//----------------------------------------------------------------------------- +//@protected members +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//@private members +//----------------------------------------------------------------------------- ScriptsDir _scriptsData = ScriptsDir(); }; -//--------------------------------------------------------------------------------------------------------------------------------------- -/** - Main rutine to start QG-Static check of scripts +//----------------------------------------------------------------------------- +/** + Main rutine to start QG-Static check of WinCC OA scripts, libs directories. + @param testType Checks WinCC OA scripts or libs directory + @param path Path to WinCCOA project to be checked. Per default this project. */ void main(string testType, string path = PROJ_PATH) { @@ -99,10 +113,13 @@ void main(string testType, string path = PROJ_PATH) } else { - DebugN("Unknown testType", testType); + OaLogger logger; + // 00051,Parameter incorrect + logger.fatal(51, "testType: " + testType, "Allowed values are 'scripts', 'libs'"); + // defensive code, shall never happens exit(-1); } - + QgStaticCheck_Scripts qg = QgStaticCheck_Scripts(); qg.checkedPath = path; exit(qg.start()); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/ErrorHdl/OaLogger.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/ErrorHdl/OaLogger.ctl new file mode 100644 index 0000000..ae4df4c --- /dev/null +++ b/WinCCOA_QualityChecks/scripts/libs/classes/ErrorHdl/OaLogger.ctl @@ -0,0 +1,113 @@ +// +// CtrlppCheck +// a static code analysis tool for WinCC OA's Ctrl language +// +// Copyright 2022 SIEMENS AG +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#uses "var" + +class OaLogger +{ +//-------------------------------------------------------------------------------- +//@public members +//-------------------------------------------------------------------------------- + + //------------------------------------------------------------------------------ + /** + */ + public OaLogger(const string msgCatalog = "") + { + this.msgCatalog = msgCatalog; + } + + //------------------------------------------------------------------------------ + /** + */ + public void info(const anytype &codeOrError, + const anytype note = NULL, + const anytype note2 = NULL, + const anytype note3 = NULL) + { + _throw(codeOrError, PRIO_INFO, note, note2, note3); + } + + //------------------------------------------------------------------------------ + /** + */ + public void warning(const anytype &codeOrError, + const anytype note = NULL, + const anytype note2 = NULL, + const anytype note3 = NULL) + { + _throw(codeOrError, PRIO_WARNING, note, note2, note3); + } + + //------------------------------------------------------------------------------ + /** + */ + public void severe(const anytype &codeOrError, + const anytype note = NULL, + const anytype note2 = NULL, + const anytype note3 = NULL) + { + _throw(codeOrError, PRIO_SEVERE, note, note2, note3); + } + + //------------------------------------------------------------------------------ + /** + */ + public void fatal(const anytype &codeOrError, + const anytype note = NULL, + const anytype note2 = NULL, + const anytype note3 = NULL) + { + _throw(codeOrError, PRIO_FATAL, note, note2, note3); + } + + + protected string msgCatalog; + //------------------------------------------------------------------------------ + /** + */ + protected _throw(const anytype &codeOrError, + const int prio, + const anytype ¬e, + const anytype ¬e2, + const anytype ¬e3) + { + dyn_errClass err; + + if (isA(codeOrError, STRING_VAR)) + { + err = makeError(msgCatalog, prio, ERR_CONTROL, 0, codeOrError); + } + if (isA(codeOrError, ERRCLASS_VAR) || isA(codeOrError, DYN_ERRCLASS_VAR)) + { + err = codeOrError; + } + else if (!isNull(note3)) + { + err = makeError(msgCatalog, prio, ERR_CONTROL, (int)codeOrError, note, note2, note3); + } + else if (!isNull(note2)) + { + err = makeError(msgCatalog, prio, ERR_CONTROL, (int)codeOrError, note, note2); + } + else if (!isNull(note)) + { + err = makeError(msgCatalog, prio, ERR_CONTROL, (int)codeOrError, note); + } + else + { + err = makeError(msgCatalog, prio, ERR_CONTROL, (int)codeOrError); + } + + if (prio == PRIO_SEVERE) + throw(err); + else + throwError(err); + } +}; \ No newline at end of file diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl index e60b884..0c6a850 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl @@ -9,6 +9,8 @@ //-------------------------------------------------------------------------------- // used libraries (#uses) +#uses "classes/ErrorHdl/OaLogger" +#uses "classes/QualityGates/Qg" //-------------------------------------------------------------------------------- // declare variables and constans @@ -39,6 +41,11 @@ class QgDir */ public void setDirPath(const string &dirPath) { + if (dirPath != "") + { + OaLogger logger; + logger.info(0, Qg::getId(), "Check directory", dirPath); + } _dirPath = dirPath; } diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl index 1733861..404d0e6 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl @@ -9,6 +9,8 @@ //-------------------------------------------------------------------------------- // used libraries (#uses) +#uses "classes/ErrorHdl/OaLogger" +#uses "classes/QualityGates/Qg" //-------------------------------------------------------------------------------- // declare variables and constans @@ -39,6 +41,11 @@ class QgFile */ public void setFilePath(const string &filePath) { + if (filePath != "") + { + OaLogger logger; + logger.info(0, Qg::getId(), "Check file", filePath); + } _filePath = filePath; } diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl index 2e4fb06..c05c7eb 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl @@ -9,6 +9,7 @@ //-------------------------------------------------------------------------------- // used libraries (#uses) +#uses "classes/ErrorHdl/OaLogger" #uses "classes/QualityGates/AddOn/FileSys/QgAddOnTmpSourceDir" #uses "classes/QualityGates/QgResultPublisher" #uses "classes/oaTest/OaTest" @@ -23,13 +24,22 @@ QgMsgCat myQgMsgCat = QgMsgCat(); OaTest myTest = OaTest(); - +//-------------------------------------------------------------------------------- +/** Error codes used in QgBase.cat +*/ +enum QgBaseError { + Exception = 1, + NotImplemented = 20, + Start, + Calculate, + Validate, + Done +}; //-------------------------------------------------------------------------------- -/*! - @brief QualityGate base class. +/** QualityGate base class. - @details Base class to handle (execute) quality gates + Base class to handle (execute) quality gates @author lschopp */ class QgBase @@ -37,6 +47,7 @@ class QgBase //-------------------------------------------------------------------------------- //@public members //-------------------------------------------------------------------------------- + //------------------------------------------------------------------------------ /** @brief QualityGate setup. * @details Function setups the QualityGate. @@ -52,7 +63,7 @@ class QgBase { myTest.setUp(); myQgMsgCat.setName(Qg::getId()); - + if (isEvConnOpen() && ( Qg::getId() != "" ) ) dpSet("_WinCCOA_qgCmd.Command", Qg::getId() + ":START"); return 0; @@ -71,25 +82,26 @@ class QgBase { if (isEvConnOpen() && ( Qg::getId() != "" ) ) dpSet("_WinCCOA_qgCmd.Command", Qg::getId() + ":START"); - + int rc = _start(); - + if (isEvConnOpen() && ( Qg::getId() != "" ) ) dpSet("_WinCCOA_qgCmd.Command", Qg::getId() + ":DONE:" + rc); - + return rc; } //------------------------------------------------------------------------------ public int calculate() { + logger.severe(QgBaseError::NotImplemented, __FUNCTION__, Qg::getId()); return 0; } //------------------------------------------------------------------------------ public int validate() { - DebugFTN("QgBase", __FUNCTION__, "You must implement some validation"); + logger.severe(QgBaseError::NotImplemented, __FUNCTION__, Qg::getId()); return -1; } @@ -156,24 +168,25 @@ class QgBase protected bool _setMinScore = FALSE; protected shared_ptr _minScoreResult; - + //------------------------------------------------------------------------------ protected int _start() { + const time startTime = getCurrentTime(); + logger.info(QgBaseError::Start, Qg::getId()); try // exceptions happen here more often, so it should be sure to stop the QG properly { _setMinScore = FALSE; - int rc; - - rc = setUp(); + int rc = setUp(); if ( rc ) { - DebugFTN("QgBase", __FUNCTION__, "setUp returns some error", rc); + logger.severe(QgBaseError::NotImplemented, __FUNCTION__, Qg::getId()); return -1; } - + if ( !_setMinScore ) { + logger.info(QgBaseError::Calculate, Qg::getId()); rc = calculate(); // ctrlppcheck-suppress knownConditionTrueFalse // the variable rc can be changed in the function calculate() in the derived class. if ( rc ) @@ -186,6 +199,7 @@ class QgBase // ctrlppcheck-suppress duplicateCondition // The variable _setMinScore can be changed in the function calculate() in the derived class. if ( !_setMinScore ) { + logger.info(QgBaseError::Validate, Qg::getId()); rc = validate(); if ( rc ) { @@ -204,18 +218,18 @@ class QgBase catch { // very dangerous - directly stop - dyn_errClass err = getLastException(); - throwError(err); - - err = makeError("QgBase", PRIO_FATAL, ERR_CONTROL, 1, Qg::getId()); - throwError(err); + logger.warning(getLastException()); + logger.fatal(QgBaseError::Exception, Qg::getId()); return -1; // defensive code, should never happen } + float duration = getCurrentTime() - startTime; + logger.info(QgBaseError::Done, Qg::getId(), duration); return 0; } - + //-------------------------------------------------------------------------------- //@private members //-------------------------------------------------------------------------------- + protected OaLogger logger = OaLogger("QgBase"); }; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSettings.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSettings.ctl index db65123..39a452f 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSettings.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSettings.ctl @@ -10,7 +10,7 @@ //----------------------------------------------------------------------------- // used libraries (#uses) #uses "classes/Variables/Mapping" -#uses "classes/WinCCOA_Json" +#uses "classes/json/JsonFile" //----------------------------------------------------------------------------- // declare variables and constans @@ -100,7 +100,6 @@ class QgSettings } else { - //DebugFTN("QgSettings", "jjjj"); return def; } } @@ -265,7 +264,7 @@ class QgSettings continue; } - Sl_Jsonfile json_file = Sl_Jsonfile(file_path); + JsonFile json_file = JsonFile(file_path); anytype json_data; int ret_val = json_file.read(json_data); @@ -329,7 +328,7 @@ class QgSettings return; } - Sl_Jsonfile json_file = Sl_Jsonfile(file_path); + JsonFile json_file = JsonFile(file_path); anytype json_data; int ret_val = json_file.read(json_data); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/CtrlCode/ScriptsDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/CtrlCode/ScriptsDir.ctl index 57be5c5..5d0dd2c 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/CtrlCode/ScriptsDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/CtrlCode/ScriptsDir.ctl @@ -49,7 +49,7 @@ class ScriptsDir : StaticCodeDir return p; } - public static ScriptsDir makeCheckSubDir(const string &fullPath) + public ScriptsDir makeCheckSubDir(const string &fullPath) { ScriptsDir dir = ScriptsDir(fullPath); return dir; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl index 4c0204d..3a1398b 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl @@ -56,7 +56,7 @@ class PanelCheck : QgFile */ public string getRelPath() { - return substr(getFilePath(), strlen(_sourceDir + PANELS_REL_PATH) ); + return substr(makeNativePath(getFilePath()), strlen(makeNativePath(_sourceDir + PANELS_REL_PATH))); } //------------------------------------------------------------------------------ @@ -141,7 +141,7 @@ class PanelCheck : QgFile if ( isExample() ) { - // do calculate example, improve performance + // do not calculate example, improve performance return 0; } @@ -169,36 +169,37 @@ class PanelCheck : QgFile // convert non xml format to a xml format, otherwise can not be loaded // _pnl.strContent = ""; string oldRelPath = _pnl.getRelPath(); - string oldPath = getPath(PANELS_REL_PATH, oldRelPath); - if( oldPath == "" ) - { - DebugFTN("PanelCheck", __FUNCTION__, "can no find panel", oldRelPath); - return -2; - } + const string originFullPath = _pnl.getFullPath(); string uuId = createUuid(); strreplace(uuId, "{", ""); strreplace(uuId, "}", ""); - string newPath = getRelPath() + uuId + ".xml"; + string newPath = uuId + ".xml"; _pnl.setPath(newPath); - newPath = getPath(PANELS_REL_PATH) + newPath; + newPath = PROJ_PATH + PANELS_REL_PATH + newPath; - copyFile(oldPath, newPath); + // copy file into current project and convert it into xml format + // conversion works only with panels located in project + copyFile(originFullPath, newPath); + const string origSourcePath = _sourceDir; + PanelFile::setSourceDirPath(PROJ_PATH); _pnl.toXml(); _pnl.read(); + int rc = _pnl.load(); + PanelFile::setSourceDirPath(origSourcePath); - if( _pnl.load() ) + if (rc) { - remove(newPath); + // remove(newPath); DebugFTN("PanelCheck", __FUNCTION__, "can not load PNL/XML panel", getRelPath()); _pnl.strContent = ""; return -1; } - remove(newPath); + // remove(newPath); if( isfile(newPath + ".bak") ) remove(newPath + ".bak"); // on converting generate the ui back up panel, so delete the waste. diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl index c9fd80d..af0fea7 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl @@ -7,33 +7,47 @@ // SPDX-License-Identifier: GPL-3.0-only // +#uses "classes/ErrorHdl/OaLogger" +#uses "classes/file/File" #uses "classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFileScript" #uses "CtrlXml" #uses "classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFileShape" class PanelFile { +//-------------------------------------------------------------------------------- +//@public members +//-------------------------------------------------------------------------------- + public dyn_anytype shapes; + public mapping properties; + public mapping events; + public string strContent; + + //------------------------------------------------------------------------------ public PanelFile(const string relPath = "") { setPath(relPath); } + //------------------------------------------------------------------------------ public void setPath(const string &relPath) { _relPath = relPath; } + //------------------------------------------------------------------------------ static public void setSourceDirPath(const string &path) { _sourceDir = path; } + //------------------------------------------------------------------------------ public bool exists() { return (_relPath != "" && isfile(getFullPath()) ); } - + //------------------------------------------------------------------------------ public int toXml() { string cmd; @@ -50,98 +64,111 @@ class PanelFile int rc = system(cmd); if ( rc ) + { + logger.warning("Can not convert panel into xml format: " + cmd); return -2; + } return 0; } + //------------------------------------------------------------------------------ public bool isBackUp() { return (strpos(getExt(_relPath), "bak") == 0); } + //------------------------------------------------------------------------------ public string getFullPath() { return _sourceDir + PANELS_REL_PATH + _relPath; } + //------------------------------------------------------------------------------ public string getRelPath() { return _relPath; } + //------------------------------------------------------------------------------ public int read() { - if ( !exists() ) - { - DebugFTN("PanelFile", __FUNCTION__, "panel does not exists", getFullPath()); - return -1; - } + File panelFile = File(getFullPath()); - fileToString(getFullPath(), strContent); + panelFile.read(this.strContent); - if ( strContent != "" ) + if ( this.strContent != "" ) { - _isXml = (strpos(strContent, " 0 ) { @@ -233,27 +264,40 @@ class PanelFile } } + //------------------------------------------------------------------------------ public int getCCN() { return _ccn; } + //------------------------------------------------------------------------------ public float getAvgCCN() { return _avgCcn; } + //------------------------------------------------------------------------------ public int getNLOC() { return _nloc; } + //------------------------------------------------------------------------------ public float getAvgNLOC() { return _avgNloc; } +//-------------------------------------------------------------------------------- +//@protected members +//-------------------------------------------------------------------------------- + + +//-------------------------------------------------------------------------------- +//@private members +//-------------------------------------------------------------------------------- + //------------------------------------------------------------------------------ int _readShapes(int node, dyn_anytype &shapes) { if ( node < 0 ) @@ -270,6 +314,7 @@ class PanelFile return 0; } + //------------------------------------------------------------------------------ int _readShape(int node, PanelFileShape &sh) { if ( node < 0 ) @@ -283,7 +328,6 @@ class PanelFile map["shapeType"] = "PANEL_REFERENCE"; // refernec does not contains the type. So push it here. } - if ( (nodeName == "shape") || (nodeName == "reference") ) { mapping props; @@ -303,7 +347,7 @@ class PanelFile break; default: - DebugFTN("PanelFile", __FUNCTION__, "!!warning undefined nodeName", nodeName); + logger.warning("InternFailure: undefined nodeName, " + nodeName + ", " + getFullPath()); } scNode = xmlNextSibling(_xmlDoc, scNode); @@ -314,11 +358,12 @@ class PanelFile sh.setEvents(events); return 0; } - - DebugFTN("PanelFile", __FUNCTION__, "unknown shape type", nodeName, map); + + logger.warning("Unknown shape type, " + nodeName + ", " + getFullPath()); return -2; } + //------------------------------------------------------------------------------ int _readEvents(int node, mapping &events) { if ( node < 0 ) @@ -335,6 +380,7 @@ class PanelFile return 0; } + //------------------------------------------------------------------------------ int _readEvent(int node, mapping &events) { if ( node < 0 ) @@ -353,12 +399,11 @@ class PanelFile events[name] = script; } - else - DebugFTN("PanelFile", __FUNCTION__, name, map); return 0; } + //------------------------------------------------------------------------------ int _readProps(int node, anytype &result) { if ( node < 0 ) @@ -392,26 +437,14 @@ class PanelFile } - public dyn_anytype shapes; - public mapping properties; - public mapping events; - public string strContent; - - + //------------------------------------------------------------------------------ bool _isXml; bool _isCrypted; - static string _sourceDir = PROJ_PATH; - string _version; - - int _xmlDoc; string _relPath; - - - int _nloc, _ccn; float _avgCcn, _avgNloc; - + OaLogger logger; }; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelsDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelsDir.ctl index c2508f0..2e46df6 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelsDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelsDir.ctl @@ -30,7 +30,7 @@ class PanelsDir : StaticCodeDir } //------------------------------------------------------------------------------ - public static PanelsDir makeCheckSubDir(const string &fullPath) + public PanelsDir makeCheckSubDir(const string &fullPath) { PanelsDir dir = PanelsDir(fullPath); return dir; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl index 1a519bd..10ff843 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl @@ -21,14 +21,14 @@ class PicturesDir : StaticDir } //------------------------------------------------------------------------------ - public static PicturesFile makeCheckFile(const string &fullPath) + public PicturesFile makeCheckFile(const string &fullPath) { PicturesFile pict = PicturesFile(fullPath); return pict; } //------------------------------------------------------------------------------ - public static PicturesDir makeCheckSubDir(const string &fullPath) + public PicturesDir makeCheckSubDir(const string &fullPath) { PicturesDir dir = PicturesDir(fullPath); return dir; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl index 6f6304f..930dc7e 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl @@ -7,6 +7,7 @@ // SPDX-License-Identifier: GPL-3.0-only // +#uses "classes/ErrorHdl/OaLogger" #uses "classes/QualityGates/QgBase" #uses "classes/QualityGates/QgStaticCheck/StaticDir" #uses "classes/QualityGates/QgSettings" @@ -44,20 +45,24 @@ class StaticCodeDir :StaticDir */ public int calculate() { - + OaLogger logger; dynClear(_files); dynClear(_childs); if ( !exists() ) + { + logger.warning(0, Qg::getId(), __FUNCTION__, "Directory does not exist", getDirPath()); return -1; + } float count = 0; // check all files dyn_string fileNames = getFileNames(getDirPath()); + for(int i = 1; i <= dynlen(fileNames); i++) { - string fullPath = makeNativePath(getDirPath() + fileNames[i]); + const string fullPath = makeNativePath(getDirPath() + fileNames[i]); anytype checkFile = makeCheckFile(fullPath); @@ -85,11 +90,11 @@ class StaticCodeDir :StaticDir // check all directories dyn_string childs = getSubDirNames(); + for(int i = 1; i <= dynlen(childs); i++) { - anytype child = makeCheckSubDir(getDirPath() + childs[i] + "/"); - if ( !child ) - continue; + const string subDirPath = makeNativePath(getDirPath() + childs[i] + "/"); + anytype child = makeCheckSubDir(subDirPath); child.calculate(); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl index 35abfd4..258de70 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl @@ -7,6 +7,7 @@ // SPDX-License-Identifier: GPL-3.0-only // +#uses "classes/ErrorHdl/OaLogger" #uses "classes/QualityGates/QgBase" #uses "classes/FileSys/QgDir" #uses "classes/QualityGates/QgSettings" @@ -37,20 +38,24 @@ class StaticDir : QgDir */ public int calculate() { + OaLogger logger; dynClear(_files); dynClear(_childs); if ( !exists() ) + { + logger.warning(0, Qg::getId(), __FUNCTION__, "Directory does not exist", getDirPath()); return -1; + } float count = 0; // check all files dyn_string fileNames = getFileNames(getDirPath()); + for(int i = 1; i <= dynlen(fileNames); i++) { - string fullPath = makeNativePath(getDirPath() + fileNames[i]); - + const string fullPath = makeNativePath(getDirPath() + fileNames[i]); anytype checkFile = makeCheckFile(fullPath); _allFilesCount++; @@ -65,9 +70,11 @@ class StaticDir : QgDir // check all directories dyn_string childs = getSubDirNames(); + for(int i = 1; i <= dynlen(childs); i++) { - anytype child = makeCheckSubDir(getDirPath() + childs[i] + "/"); + const string subDirPath = makeNativePath(getDirPath() + childs[i] + "/"); + anytype child = makeCheckSubDir(subDirPath); if ( child.calculate() ) continue; // only for safety (should never occur) @@ -87,7 +94,6 @@ class StaticDir : QgDir QgVersionResult::lastErr = ""; -// result.clear(); result = new QgVersionResult(); result.text = getName(); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSyntaxCheck/QgSyntaxCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSyntaxCheck/QgSyntaxCheck.ctl index 47fc2fe..d9bfdca 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSyntaxCheck/QgSyntaxCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgSyntaxCheck/QgSyntaxCheck.ctl @@ -160,7 +160,7 @@ class QgSyntaxCheck : QgBase } } - DebugFN("QgSyntaxCheck", __FUNCTION__, "add message to bad-list"); + DebugFTN("QgSyntaxCheck", __FUNCTION__, "add message to bad-list"); assertion.assertTrue(FALSE, settings.getScorePoints()); _result.addChild(assertion); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgVersionResult.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgVersionResult.ctl index b087fbe..31ada5d 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgVersionResult.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgVersionResult.ctl @@ -201,6 +201,7 @@ struct QgVersionResult return errorPoints; } + //------------------------------------------------------------------------------ public void toStdOut() { DebugN(__FUNCTION__, text, assertKey, dynlen(children), lowerBound, upperBound, referenceValue); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Json.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Json.ctl deleted file mode 100644 index 34d4f1c..0000000 --- a/WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Json.ctl +++ /dev/null @@ -1,183 +0,0 @@ -// -// CtrlppCheck -// a static code analysis tool for WinCC OA's Ctrl language -// -// Copyright 2022 SIEMENS AG -// -// SPDX-License-Identifier: GPL-3.0-only -// - -#uses "json" -#uses "classes/WinCCOA_Logger" - -//--------------------------------------------------------------------------------------------------------------------------------------- -/*!JSON file handler. - @author ataker - */ -class Sl_Jsonfile -{ - private static Sl_Logger LOGGER = Sl_Logger(); - private string filePath; /*!< full path to the json file */ - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - JSON file handler. - - @param filePath Absolute filepath of an (existing) file. - @param createFile When TRUE file will be created when it is not existing - - @author ataker - */ - public Sl_Jsonfile(const string filePath = "", bool createFile = false) - { - this.filePath = filePath; - - if ( createFile && !(this.exists()) ) - { - this.create(); - } - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Function the absolute file path to the jenkisn file - @return absolute path to jenkins file - */ - public string getPath() - { - return this.filePath; - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Function sets path to the jenkins file. - - @param filePath Absolute filepath of an (existing) file. - */ - public void setPath(string filePath) - { - this.filePath = filePath; - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Function checks if the file exists. - @return Returns TRUE if the file exists, otherwise FALSE. - */ - public bool exists() - { - LOGGER.info("["+__FUNCTION__+"] Check if file exist."); - return isfile(this.filePath); - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Function creates the file if it does not exist. - @return error code: - \li 0 File was created successfully. - \li -1 Missing file path. - \li -2 File already exists. - \li -3 File couldn't be created. - */ - public int create() - { - if ( this.filePath == "" ) - { - LOGGER.warning("["+__FUNCTION__+"] Missing file path."); - return -1; - } - - if ( this.exists() ) - { - LOGGER.warning("["+__FUNCTION__+"] File already exists."); - return -2; - } - - LOGGER.info("["+__FUNCTION__+"] Convert file to string. File path: " + this.filePath); - if ( fclose(fopen(this.filePath, "wb+")) ) - { - LOGGER.severe("["+__FUNCTION__+"] Could not create file."); - return -3; - } - - return 0; - } - - //------------------------------------------------------------------------------------------------------------------------------------- - /** - Function reads a file and returns the decrypted JSON string. - @param jsonVal Reference value which contains the decrypted JSON string - @return error code: - \li 0 Data was read successfully. - \li -1 File can't be read. - \li -2 Missing internal arguments. - - @warning refrence value jsonVal are not cleared in case of error. - */ - public int read(anytype &jsonVal) - { - - if ( access(this.filePath, R_OK) ) - { - LOGGER.severe("["+__FUNCTION__+"] File can't be read."); - return -1; - } - - string json; - - LOGGER.info("["+__FUNCTION__+"] Convert file to string. File path: " + this.filePath); - if ( !fileToString(this.filePath, json) || json == "" ) - { - LOGGER.severe("["+__FUNCTION__+"] Missing arguments."); - return -2; - } - - LOGGER.info("["+__FUNCTION__+"] Decode json string"); - jsonVal = json_strToVal(json); - return 0; - } - - //------------------------------------------------------------------------------------------------------------------------------------- - /** - Writes data in the form of a JSON string to the specified file. - @param data Data to be written to the files. - @param compactFormat Format of JSON string. True means compact, False means human readable format. - @return error code: - \li 0 Data was successfully written to the file as a JSON string. - \li -1 File is not available. - \li -2 An error occurred. - \li -3 Couldn't write string into file. - */ - public int write(const anytype &data, bool compactFormat = FALSE) - { - if ( access(this.filePath, W_OK) ) - { - LOGGER.severe("["+__FUNCTION__+"] File is not available."); - return -1; - } - - LOGGER.info("["+__FUNCTION__+"] Opening file. File path: " + this.filePath); - file f = fopen(this.filePath, "wb+"); - - int err = ferror(f); //Output possible errors - if ( err != 0 ) - { - LOGGER.severe("["+__FUNCTION__+"] An error occurred. Error code: " + err); - return -2; - } - - string json = jsonEncode(data, compactFormat); - - LOGGER.info("["+__FUNCTION__+"] Write json string into file."); - err = fputs(json, f); - fclose(f); - - if ( err >= 0 ) - { - LOGGER.severe("["+__FUNCTION__+"] Couldn't write string into file"); - return -3; - } - - return 0; - } -}; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Logger.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Logger.ctl deleted file mode 100644 index 987a558..0000000 --- a/WinCCOA_QualityChecks/scripts/libs/classes/WinCCOA_Logger.ctl +++ /dev/null @@ -1,209 +0,0 @@ - -// -// CtrlppCheck -// a static code analysis tool for WinCC OA's Ctrl language -// -// Copyright 2022 SIEMENS AG -// -// SPDX-License-Identifier: GPL-3.0-only -// - -//--------------------------------------------------------------------------------------------------------------------------------------- -/*! Describes the notification level of the message */ -enum Sl_LogLevel -{ - SEVERE, /*!< Messages that inform the user about an error and require immediate action.*/ - WARNING, /*!< Messages that notify the user about an error, but there is no immediate need for action.*/ - INFO, /*!< Messages that should only inform the user*/ - FINE /*!< Messages that inform the user about a success.*/ -}; - -//--------------------------------------------------------------------------------------------------------------------------------------- -/*! - Class Sl_Logger represented logger that handled with WinCC OA Log messages. - @author ataker -*/ -class Sl_Logger -{ - /// @cond - private string logFile = "AbstractionLayer_Log.txt"; /*!< log file name */ - /// @endcond - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Default c-tor - */ - public Sl_Logger () - { - string path = getPath(DATA_REL_PATH) + "WinCCOA/"; - if ( !isdir(path) ) - { - mkdir(path); - } - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Function throw (logs) a message and object with the specified level. - @param level Notification level from the enum level - @param msg Message to be logged. - @param obj Object to be logged. - */ - public void logObj(Sl_LogLevel level, const string &msg, const anytype &obj) - { - switch(level) - { - case Sl_LogLevel::INFO: - DebugFTN("Info", msg, obj); - writeToLog("Info", msg, obj); - break; - - case Sl_LogLevel::FINE: - DebugFTN("Fine", msg, obj); - writeToLog("Fine", msg, obj); - break; - - case Sl_LogLevel::WARNING: - DebugFTN("Warning", msg, obj); - writeToLog("Warning", msg, obj); - break; - - case Sl_LogLevel::SEVERE: - DebugFTN("Severe", msg, obj); - writeToLog("Severe", msg, obj); - break; - - } - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Only logs a message with a specific notification level. - @param level Notification level from the enum level - @param msg Message to be logged. - */ - public void logMsg(Sl_LogLevel level, const string &msg) - { - logObj(level, msg, ""); - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Logs a message with the level info - @param msg Message to be logged. - */ - public void info(const string &msg) - { - logMsg(Sl_LogLevel::INFO, msg); - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Logs a message with the level warning - @param msg Message to be logged. - */ - public void warning(const string &msg) - { - logMsg(Sl_LogLevel::WARNING, msg); - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Logs a message with the level fine - @param msg Message to be logged. - */ - public void fine(const string &msg) - { - logMsg(Sl_LogLevel::FINE, msg); - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Logs a message with the level severe - @param msg Message to be logged. - */ - public void severe(const string &msg) - { - logMsg(Sl_LogLevel::SEVERE, msg); - } - - - //--------------------------------------------------------------------------------------------------------------------------------------- - // private members not relevant for docu - /// @cond - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - Logs a message and object with the specified level to the logfile. The file is saved under the data path. - @param type Notification level from the enum level - @param msg Message to be logged. - @param obj Object to be logged. - */ - private void writeToLog(string type, const string &msg, const anytype &obj) - { - string logPath = getPath(DATA_REL_PATH) + "WinCCOA/"; - - if ( !isdir(logPath) ) - { - mkdir(logPath); - } - - file f = fopen(logPath + logFile ,"a+"); - int err = ferror(f); //Output possible errors - if ( err ) - { - DebugN("[Logger]["+__FUNCTION__+"] Error no. " + err + " occurred"); - return; - } - - time currentTime = getCurrentTime(); - string content = formatTime("%c" ,currentTime) + " " + msg + "\n"; - fputs(content, f); //Write to the file - - fclose(f); //Close file - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - internall use only - @param ret return code from checked function - @param error dyn_errClass returned from checked function via getLastError() - @return true when error are throwed, otherwise false - */ - private bool _errorHandling(int ret, dyn_errClass error = getLastError()) - { - if ( ret < 0 ) - { - DebugTN(__FUNCTION__, error); - - //LOGGER - throwError(error); - return true; - } - - return false; - } - - //--------------------------------------------------------------------------------------------------------------------------------------- - /** - internall use only - @param map - @param key - @return any - */ - private anytype get(mapping map, string key) - { - if ( mappinglen(map) >= 0 ) return -1; - - if ( mappingHasKey(map, key) ) - { - return map[key]; - } - - return -1; - } - /// @endcond - - //--------------------------------------------------------------------------------------------------------------------------------------- - -}; From 4e016c44440cba202c3efeede25482cd9b8b5636 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sat, 6 May 2023 13:47:40 +0200 Subject: [PATCH 03/22] remove xml copy files --- .../data/ctrlPpCheck/cfg/ctrl.xml | 3316 +++++++++++++++++ .../QgStaticCheck/Panels/PanelCheck.ctl | 4 +- 2 files changed, 3318 insertions(+), 2 deletions(-) create mode 100644 WinCCOA_QualityChecks/data/ctrlPpCheck/cfg/ctrl.xml diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/cfg/ctrl.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/cfg/ctrl.xml new file mode 100644 index 0000000..119abf7 --- /dev/null +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/cfg/ctrl.xml @@ -0,0 +1,3316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inconclusive + + + + + + inconclusive + + + + + + + inconclusive + + + + + + + + inconclusive + + + + + + + inconclusive + + + + + + + + + inconclusive + + + + + + + inconclusive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl index 3a1398b..ef66e16 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl @@ -192,14 +192,14 @@ class PanelCheck : QgFile if (rc) { - // remove(newPath); + remove(newPath); DebugFTN("PanelCheck", __FUNCTION__, "can not load PNL/XML panel", getRelPath()); _pnl.strContent = ""; return -1; } - // remove(newPath); + remove(newPath); if( isfile(newPath + ".bak") ) remove(newPath + ".bak"); // on converting generate the ui back up panel, so delete the waste. From 9532fdb94c07643e0d2d702c6f37da968ea3a4c1 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sat, 6 May 2023 14:17:42 +0200 Subject: [PATCH 04/22] filter only failures from source code --- .../QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl index f4c0f52..92b722f 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl @@ -85,6 +85,8 @@ class QgCtrlppCheck : QgBase if ( f.isExample() || f.isTest() || !f.isPatternMatch(includeFilesPattern) ) continue; + + if ( isErrorFiltered(error) ) continue; @@ -162,6 +164,15 @@ class QgCtrlppCheck : QgBase /// Checks if the error shall be filtered. protected bool isErrorFiltered(const CppCheckError &error) { + /// @todo it shallbe somehow configurable and + /// done in the ctrlppcheck (in cpp source) to eliminate CPU usage + if (!error.path.isEmpty() && !makeUnixPath(error.path).startsWith(makeUnixPath(this.checkedPath))) + { + // inform only about failures in checked sources. + // No body interested about sub-project failures + return FALSE; + } + if ( error.msg == "" ) return TRUE; From 9f081e68f5d343e36ec3a2dbf363e09c68837309 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sat, 6 May 2023 15:42:58 +0200 Subject: [PATCH 05/22] other fixes --- .../scripts/libs/classes/FileSys/QgDir.ctl | 7 ------ .../scripts/libs/classes/FileSys/QgFile.ctl | 7 ------ .../QgCtrlppCheck/QgCtrlppCheck.ctl | 22 ++++++++++--------- .../QgOverloadedFilesCheck.ctl | 5 +++++ .../QgStaticCheck/Pictures/PicturesDir.ctl | 1 + .../QgStaticCheck/StaticCodeDir.ctl | 2 ++ .../QualityGates/QgStaticCheck/StaticDir.ctl | 3 +++ .../QualityGates/Tools/CppCheck/CppCheck.ctl | 4 ++++ .../Tools/CppCheck/CppCheckError.ctl | 1 + docs/namingCheck.md | 2 +- 10 files changed, 29 insertions(+), 25 deletions(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl index 0c6a850..e60b884 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgDir.ctl @@ -9,8 +9,6 @@ //-------------------------------------------------------------------------------- // used libraries (#uses) -#uses "classes/ErrorHdl/OaLogger" -#uses "classes/QualityGates/Qg" //-------------------------------------------------------------------------------- // declare variables and constans @@ -41,11 +39,6 @@ class QgDir */ public void setDirPath(const string &dirPath) { - if (dirPath != "") - { - OaLogger logger; - logger.info(0, Qg::getId(), "Check directory", dirPath); - } _dirPath = dirPath; } diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl index 404d0e6..1733861 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/FileSys/QgFile.ctl @@ -9,8 +9,6 @@ //-------------------------------------------------------------------------------- // used libraries (#uses) -#uses "classes/ErrorHdl/OaLogger" -#uses "classes/QualityGates/Qg" //-------------------------------------------------------------------------------- // declare variables and constans @@ -41,11 +39,6 @@ class QgFile */ public void setFilePath(const string &filePath) { - if (filePath != "") - { - OaLogger logger; - logger.info(0, Qg::getId(), "Check file", filePath); - } _filePath = filePath; } diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl index 92b722f..4662866 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl @@ -81,20 +81,15 @@ class QgCtrlppCheck : QgBase { CppCheckError error = check.errList[i]; - QgFile f = QgFile(error.path); - if ( f.isExample() || f.isTest() || !f.isPatternMatch(includeFilesPattern) ) - continue; - - - if ( isErrorFiltered(error) ) continue; + QgFile f = QgFile(error.path); string relPath = f.getRelPath(SCRIPTS_REL_PATH); shared_ptr assertion = new QgVersionResult(); assertion.setMsgCatName("QgCtrlppCheck"); - assertion.setAssertionText(relPath + " : " + error.line); + assertion.setAssertionText(makeUnixPath(relPath)); assertion.setReasonText(error.msg + " (" + error.id + ")"); assertion.assertEqual(error.severity, ""); _result.addChild(assertion); @@ -139,6 +134,8 @@ class QgCtrlppCheck : QgBase // } else { + check.settings.inlineSuppressions = TRUE; + check.settings.includeSubProjects = FALSE; check.settings.enableCheckLibrary(FALSE); } @@ -166,13 +163,17 @@ class QgCtrlppCheck : QgBase { /// @todo it shallbe somehow configurable and /// done in the ctrlppcheck (in cpp source) to eliminate CPU usage - if (!error.path.isEmpty() && !makeUnixPath(error.path).startsWith(makeUnixPath(this.checkedPath))) + if (error.path != error.path0) { // inform only about failures in checked sources. - // No body interested about sub-project failures - return FALSE; + // No body interested about sub-project failures. + return TRUE; } + QgFile f = QgFile(error.path); + if ( f.isExample() || f.isTest() || !f.isPatternMatch(includeFilesPattern) ) + return true; + if ( error.msg == "" ) return TRUE; @@ -185,6 +186,7 @@ class QgCtrlppCheck : QgBase if ( dynContains(disabledSeverities, severity) ) return TRUE; + return FALSE; } diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgOverloadedFilesCheck/QgOverloadedFilesCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgOverloadedFilesCheck/QgOverloadedFilesCheck.ctl index 9794dcf..fdcfefa 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgOverloadedFilesCheck/QgOverloadedFilesCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgOverloadedFilesCheck/QgOverloadedFilesCheck.ctl @@ -7,6 +7,7 @@ // SPDX-License-Identifier: GPL-3.0-only // +#uses "classes/ErrorHdl/OaLogger" #uses "classes/QualityGates/QgBase" #uses "classes/QualityGates/QgSettings" #uses "fileSys" @@ -69,6 +70,7 @@ class QgOverloadedFilesCheck SCRIPTS_REL_PATH + "userPara.ctl", LIBS_REL_PATH + "aesuser.ctl", LIBS_REL_PATH + "asModifyDisplay.ctl", + LIBS_REL_PATH + "classes/oaTest/OaTest.ctl", // (officially not part of product) LIBS_REL_PATH + "driverSettings_HOOK.ctl", PANELS_REL_PATH + "vision/aes/_AS_propFilterExtended.pnl", @@ -81,12 +83,15 @@ class QgOverloadedFilesCheck */ public int calculate() { + OaLogger logger; dyn_string files = getFileNamesRecursive(PROJ_PATH); dynSort(files); // for(int i = 1; i <= dynlen(files); i++) { string path = files[i]; + logger.info(0, Qg::getId(), "Check file", path); + const string relPath = substr(path, strlen(PROJ_PATH)); if ( strpos(relPath, makeNativePath(CONFIG_REL_PATH)) == 0 || diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl index 10ff843..952e003 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Pictures/PicturesDir.ctl @@ -46,6 +46,7 @@ class PicturesDir : StaticDir return 0; } + //------------------------------------------------------------------------------ public string getSettingsRoot() { return "PicturesDir"; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl index 930dc7e..39d4275 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticCodeDir.ctl @@ -46,6 +46,7 @@ class StaticCodeDir :StaticDir public int calculate() { OaLogger logger; + logger.info(0, Qg::getId(), "Check directory", getDirPath()); dynClear(_files); dynClear(_childs); @@ -63,6 +64,7 @@ class StaticCodeDir :StaticDir for(int i = 1; i <= dynlen(fileNames); i++) { const string fullPath = makeNativePath(getDirPath() + fileNames[i]); + logger.info(0, Qg::getId(), "Check file", fullPath); anytype checkFile = makeCheckFile(fullPath); diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl index 258de70..cf733b3 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl @@ -39,6 +39,8 @@ class StaticDir : QgDir public int calculate() { OaLogger logger; + logger.info(0, Qg::getId(), "Check directory", getDirPath()); + dynClear(_files); dynClear(_childs); @@ -56,6 +58,7 @@ class StaticDir : QgDir for(int i = 1; i <= dynlen(fileNames); i++) { const string fullPath = makeNativePath(getDirPath() + fileNames[i]); + logger.info(0, Qg::getId(), "Check file", fullPath); anytype checkFile = makeCheckFile(fullPath); _allFilesCount++; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheck.ctl index d10c1f4..97278cb 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheck.ctl @@ -233,6 +233,10 @@ class CppCheck mapping map = xmlElementAttributes(docNum, node); err.line = (int)map["line"]; err.path = map["file"]; + + if (mappingHasKey(map, "file0")) + err.path0 = map["file0"]; + return 0; } return -1; diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheckError.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheckError.ctl index db40497..c4ec71f 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheckError.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/Tools/CppCheck/CppCheckError.ctl @@ -7,6 +7,7 @@ struct CppCheckError string msg; string verbose; string path; + string path0; int line; int cwe; string knownBug; // for internal use (tests) diff --git a/docs/namingCheck.md b/docs/namingCheck.md index 44bf0e6..b615eab 100644 --- a/docs/namingCheck.md +++ b/docs/namingCheck.md @@ -102,7 +102,7 @@ Either all three categories must be defined or only one. ## Check process -1. All rules will be searched if theere is a perfect match between an variable and a certain id: +1. All rules will be searched if there is a perfect match between an variable and a certain id: **Example**: Variable: From ee211ecf72a8c005b1987d887272b4f006c91d8a Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 00:50:25 +0200 Subject: [PATCH 06/22] ctrl rule file has wrong name, therefore never used --- .../rule/{ctrl_rules.xml => ctrl.xml} | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) rename WinCCOA_QualityChecks/data/ctrlPpCheck/rule/{ctrl_rules.xml => ctrl.xml} (77%) diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_rules.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml similarity index 77% rename from WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_rules.xml rename to WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml index 36db7ce..c40f7b1 100644 --- a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_rules.xml +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml @@ -98,7 +98,7 @@ StrlenNotEmptyString performance - Using strlen() to check if a string is not empty, is not efficient. + Using strlen() to check if a string is not empty, is not efficient. Use string::isEmpty() instead. @@ -106,7 +106,7 @@ StrlenEmptyString performance - Using strlen() to check if a string is empty, is not efficient. + Using strlen() to check if a string is empty, is not efficient. Use string::isEmpty() instead. @@ -115,7 +115,7 @@ strPosEq0 performance - Using strpos(s) == 0 to check if the string start with other string is not efficient. + Using strpos(s) == 0 to check if the string start with other string is not efficient. Use string::startsWith() instead. @@ -149,3 +149,31 @@ + + normal + system \( \S+ + + quoted_params_system + error + Call function system() with unquoted parameters. + + Calling function system() with unquoted parameters leads to issues, when spaces in parameter are used. + For example, when the program is located in path containing spaces. + Verify, that the system call has quoted parameters and suppres this error by + //ctrlppcheck-suppress quoted_params_system + + + + normal + system \( \S+ + + unsafe_system_call + warning + Calling system command outside WinCC OA. + + Calling system command outside WinCC OA may be dangerours. + This is potential security issue. + Verify that this operation is safe and suppres this warning by + //ctrlppcheck-suppress unsafe_system_call + + From ae6f6ffe472ebee338343d21db81069bbcc27ea8 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 02:30:08 +0200 Subject: [PATCH 07/22] docu --- README.md | 2 +- ctrlppcheck/docuSources/ctrlPppCheckUsage.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3c71c6e..fda4b13 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Introduction ------------ WinCC OA CtrlppCheck is a set of tools for static code analysis for SIMATIC WinCC OA's scripting language Ctrl and Ctrl++. -It supports all versions of WinCC OA and is optimised for versions 3.19 and higher. +It supports all versions of WinCC OA and is optimized for versions 3.19 and higher. They are easy to use and integrate perfectly with WinCC OA's script editor GEDI but may also be used in an CI toolchain for automated pull request builds etc. Community Resources diff --git a/ctrlppcheck/docuSources/ctrlPppCheckUsage.md b/ctrlppcheck/docuSources/ctrlPppCheckUsage.md index a223f3c..43c95e7 100644 --- a/ctrlppcheck/docuSources/ctrlPppCheckUsage.md +++ b/ctrlppcheck/docuSources/ctrlPppCheckUsage.md @@ -272,7 +272,7 @@ To suppress the error message, a comment can be added: void main() { int i; - // cppcheck-suppress uninitvar + // ctrlppcheck-suppress uninitvar if ( i > 0 ) { i++; @@ -289,13 +289,13 @@ cppcheck --inline-suppr file1.ctl you can specify that the inline suppression only applies to a specific symbol: ``` -// cppcheck-suppress uninitvar symbolName=arr +// ctrlppcheck-suppress uninitvar symbolName=arr ``` You can write comments for the suppress, however, is recommended to use ; or // to specify where they start: ``` -// cppcheck-suppress uninitvar ; some comment -// cppcheck-suppress uninitvar // some comment +// ctrlppcheck-suppress uninitvar ; some comment +// ctrlppcheck-suppress uninitvar // some comment ``` ## Library configuration From c0fb99f061ac44f24697b3d8d4f95744900ce9b0 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 02:30:22 +0200 Subject: [PATCH 08/22] some rules --- .../data/ctrlPpCheck/rule/ctrl.xml | 45 +++++++++++++++++++ .../data/ctrlPpCheck/rule/ctrl_3.20.xml | 21 +++++++++ .../data/ctrlPpCheck/rule/variableNaming.xml | 4 ++ 3 files changed, 70 insertions(+) create mode 100644 WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml index c40f7b1..c2ccc9e 100644 --- a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml @@ -177,3 +177,48 @@ //ctrlppcheck-suppress unsafe_system_call + + raw + makeError \( \S+ , \S+ , \S+ , 0 + + fatal_program_exit + warning + Throw error with FATAL priority stop the program. + + Throwing a error with FATAL priority leads to stop the program. + Verify that this scenario is accepted and suppres this warning by + //ctrlppcheck-suppress fatal_program_exit + + + + + raw + logger . fatal \( + + fatal_program_exit + warning + Throw error with FATAL priority stop the program. + + Throwing a error with FATAL priority leads to stop the program. + Verify that this scenario is accepted and suppres this warning by + //ctrlppcheck-suppress fatal_program_exit + + + + normal + uses \".*\.ctl\" + + library_extension + style + It is not neccessary to use .ctl extension in #uses. + + + + normal + uses \".*\.ctc\" + + library_extension + style + It is not neccessary to use .ctc extension in #uses. + + diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml new file mode 100644 index 0000000..8819c76 --- /dev/null +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml @@ -0,0 +1,21 @@ + + + + + + + + raw + uses \"stdVar\" + + obsolete_uses_stdVar + warning + Library 'stdVar.ctl' is deprecated. Please use library std.ctl. + + + + \ No newline at end of file diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml index 265e960..fc533f8 100644 --- a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml @@ -7,6 +7,9 @@ simple --> + ^.+$ From 778f9f6dd3922cadc653eec60cb168a3558c8d09 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 11:26:31 +0200 Subject: [PATCH 09/22] extend gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..737d28a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +WinCCOA_QualityChecks/bin/ctrlppcheck/ From 09a8adb4365fe4760d2ee07bffbee48d2e238f1f Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 12:37:52 +0200 Subject: [PATCH 10/22] extend git ignore for locale builds --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 737d28a..129733e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ WinCCOA_QualityChecks/bin/ctrlppcheck/ +ctrlppcheck/build/ From 08c98fa627d13dc009cb89fe3db85a2dab80a101 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 12:40:54 +0200 Subject: [PATCH 11/22] allow ctrlppcheck-suppress instead of cppcheck-suppress --- WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml | 4 ---- .../tests/ctrlppCheck/testscripts/testUndeclaredVariable.ctl | 2 +- ctrlppcheck/cli/cmdlineparser.cpp | 2 +- ctrlppcheck/cli/cppcheckexecutor.cpp | 2 +- ctrlppcheck/lib/suppressions.cpp | 3 ++- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml index c2ccc9e..cdfd6d5 100644 --- a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl.xml @@ -156,7 +156,6 @@ quoted_params_system error Call function system() with unquoted parameters. - Calling function system() with unquoted parameters leads to issues, when spaces in parameter are used. For example, when the program is located in path containing spaces. Verify, that the system call has quoted parameters and suppres this error by @@ -170,7 +169,6 @@ unsafe_system_call warning Calling system command outside WinCC OA. - Calling system command outside WinCC OA may be dangerours. This is potential security issue. Verify that this operation is safe and suppres this warning by @@ -184,7 +182,6 @@ fatal_program_exit warning Throw error with FATAL priority stop the program. - Throwing a error with FATAL priority leads to stop the program. Verify that this scenario is accepted and suppres this warning by //ctrlppcheck-suppress fatal_program_exit @@ -198,7 +195,6 @@ fatal_program_exit warning Throw error with FATAL priority stop the program. - Throwing a error with FATAL priority leads to stop the program. Verify that this scenario is accepted and suppres this warning by //ctrlppcheck-suppress fatal_program_exit diff --git a/WinCCOA_QualityChecks_tests/scripts/tests/ctrlppCheck/testscripts/testUndeclaredVariable.ctl b/WinCCOA_QualityChecks_tests/scripts/tests/ctrlppCheck/testscripts/testUndeclaredVariable.ctl index 8699946..5a324c9 100644 --- a/WinCCOA_QualityChecks_tests/scripts/tests/ctrlppCheck/testscripts/testUndeclaredVariable.ctl +++ b/WinCCOA_QualityChecks_tests/scripts/tests/ctrlppCheck/testscripts/testUndeclaredVariable.ctl @@ -12,7 +12,7 @@ void main() unknownVar = 1; // test to supress this message - // cppcheck-suppress undeclaredVariable + // ctrlppcheck-suppress undeclaredVariable unknownVar = 2; // ctrlppcheck-suppress undeclaredVariable unknownVar = 3; diff --git a/ctrlppcheck/cli/cmdlineparser.cpp b/ctrlppcheck/cli/cmdlineparser.cpp index 3bad3b5..c96b234 100644 --- a/ctrlppcheck/cli/cmdlineparser.cpp +++ b/ctrlppcheck/cli/cmdlineparser.cpp @@ -767,7 +767,7 @@ void CmdLineParser::printHelp() " must be carefully investigated before you know if it is\n" " good or bad.\n" " --inline-suppr Enable inline suppressions. Use them by placing one or\n" - " more comments, like: '// cppcheck-suppress warningId'\n" + " more comments, like: '// ctrlppcheck-suppress warningId'\n" " on the lines before the warning to suppress.\n" " --language=, -x \n" " Forces cppcheck to check all files as the given\n" diff --git a/ctrlppcheck/cli/cppcheckexecutor.cpp b/ctrlppcheck/cli/cppcheckexecutor.cpp index c1236c5..419b45c 100644 --- a/ctrlppcheck/cli/cppcheckexecutor.cpp +++ b/ctrlppcheck/cli/cppcheckexecutor.cpp @@ -498,7 +498,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) break; } fprintf(output, " (%sat 0x%lx).%s\n", - // cppcheck-suppress knownConditionTrueFalse ; FP + // ctrlppcheck-suppress knownConditionTrueFalse ; FP (type==-1)? "" : (type==0) ? "reading " : "writing ", (unsigned long)info->si_addr, diff --git a/ctrlppcheck/lib/suppressions.cpp b/ctrlppcheck/lib/suppressions.cpp index a51f5e3..bfb7791 100644 --- a/ctrlppcheck/lib/suppressions.cpp +++ b/ctrlppcheck/lib/suppressions.cpp @@ -210,7 +210,8 @@ bool Suppressions::Suppression::parseComment(std::string comment, std::string *e std::istringstream iss(comment.substr(2)); std::string word; iss >> word; - if (word != "cppcheck-suppress" && word != "cppcheck-suppress") + if (word != "cppcheck-suppress" && word != "cppcheck-suppress" && + word != "ctrlppcheck-suppress" && word != "ctrlppcheck-suppress") return false; iss >> errorId; if (!iss) From 4963c4d2b949de93dba091133e018ab3745bfcee Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 21:43:32 +0200 Subject: [PATCH 12/22] allow to check any directory --- .../QgCtrlppCheck/QgCtrlppCheck.ctl | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl index 4662866..27f1137 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl @@ -25,7 +25,7 @@ class QgCtrlppCheck : QgBase //-------------------------------------------------------------------------------- //@public members //-------------------------------------------------------------------------------- - public string checkedPath = PROJ_PATH; + public string checkedPath = PROJ_PATH + SCRIPTS_REL_PATH; //------------------------------------------------------------------------------ /** @brief Calculates / start ctrlppcheck. @@ -34,7 +34,7 @@ class QgCtrlppCheck : QgBase */ public int calculate() { - return checkDir(this.checkedPath + SCRIPTS_REL_PATH); + return checkDir(this.checkedPath); } //------------------------------------------------------------------------------ @@ -61,14 +61,6 @@ class QgCtrlppCheck : QgBase "_CtrlppCheck.filter.severity", disabledSeverities); includeFilesPattern = "*"; } - // else if ( Qg::isRunningOnJenkins() ) - // { - // disabledIds = makeDynString("debug", "unreadVariable", - // "checkLibraryFunction", "checkLibraryNoReturn", - // "unusedFunction"); - // disabledSeverities = makeDynString("debug", "information"); - // includeFilesPattern = makeUnixPath(dirPath + "*"); - // } else { disabledIds = makeDynString("debug", "unreadVariable", @@ -123,20 +115,18 @@ class QgCtrlppCheck : QgBase "_CtrlppCheck.settings.verbose", check.settings.verbose, "_CtrlppCheck.settings.inlineSuppressions", check.settings.inlineSuppressions); } - // else if ( Qg::isRunningOnJenkins() ) - // { - // check.settings.enableLibCheck = FALSE; - // check.settings.enableHeadersCheck = TRUE; - // check.settings.includeSubProjects = TRUE; - // check.settings.inconclusive = FALSE; - // check.settings.verbose = FALSE; - // check.settings.inlineSuppressions = TRUE; - // } else { + ///@todo this shall be somehove configurable + /// but current QG-settings concept does not + /// support it. + /// It is not a big problem, because you can import + /// dp-list with _CtrlppCheck and use the code above. check.settings.inlineSuppressions = TRUE; - check.settings.includeSubProjects = FALSE; + check.settings.includeSubProjects = TRUE; + check.settings.inconclusive = FALSE; check.settings.enableCheckLibrary(FALSE); + check.settings.verbose = FALSE; } // load configs @@ -200,7 +190,7 @@ class QgCtrlppCheck : QgBase /// Start Qg ctrlppcheck. /// Simple old ctrl style. -public int start_QgCtrlppCheck(string path = PROJ_PATH) +public int start_QgCtrlppCheck(string path = PROJ_PATH + SCRIPTS_REL_PATH) { Qg::setId("QgCtrlppCheck"); QgCtrlppCheck qg = QgCtrlppCheck(); From cd12a5f8c8f02f1b7ed4c264119c89f58049e2f5 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 7 May 2023 21:55:59 +0200 Subject: [PATCH 13/22] allow to check any picture, scripts or libs directory --- .../QualityGates/StaticTests/QgPicturesCheck.ctl | 6 +++--- .../QualityGates/StaticTests/QgScriptsCheck.ctl | 16 ++++++++++++---- .../QualityGates/QgStaticCheck/StaticDir.ctl | 5 ++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPicturesCheck.ctl b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPicturesCheck.ctl index 71cc6cf..ff525fb 100644 --- a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPicturesCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgPicturesCheck.ctl @@ -27,7 +27,7 @@ class QgStaticCheck_Pictures : QgBase //-------------------------------------------------------------------------------- //@public members //-------------------------------------------------------------------------------- - public string checkedPath = PROJ_PATH; + public string checkedPath = PROJ_PATH + PICTURES_REL_PATH; //------------------------------------------------------------------------------ /** @brief Function setups pictures tests. @@ -40,7 +40,7 @@ class QgStaticCheck_Pictures : QgBase return -1; throwError(makeError("", PRIO_INFO, ERR_CONTROL, 0, Qg::getId() + " will check " + this.checkedPath + PICTURES_REL_PATH)); - _pictures.setDir(this.checkedPath + PICTURES_REL_PATH); + _pictures.setDir(this.checkedPath); if ( !_pictures.exists() ) setMinValidScore("QgStaticCheck_Pictures", "assert.missingPictures", "reason.missingPictures"); @@ -93,7 +93,7 @@ class QgStaticCheck_Pictures : QgBase /** @breif main rutine to start QualityGate QgStaticCheck-Pictures */ -void main(string path = PROJ_PATH) +void main(string path = PROJ_PATH + PICTURES_REL_PATH) { Qg::setId("QgStaticCheck_Pictures"); QgStaticCheck_Pictures qg = QgStaticCheck_Pictures(); diff --git a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl index 1531d62..b196943 100644 --- a/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/QualityGates/StaticTests/QgScriptsCheck.ctl @@ -27,7 +27,7 @@ class QgStaticCheck_Scripts : QgBase //----------------------------------------------------------------------------- //@public members //----------------------------------------------------------------------------- - public string checkedPath = PROJ_PATH; + public string checkedPath = ""; //--------------------------------------------------------------------------- public int setUp() @@ -40,12 +40,20 @@ class QgStaticCheck_Scripts : QgBase if ( Qg::getId() == "QgStaticCheck_Scripts" ) { - _scriptsData.setDir(this.checkedPath + SCRIPTS_REL_PATH); + if (this.checkedPath.isEmpty()) + { + this.checkedPath = PROJ_PATH + SCRIPTS_REL_PATH; + } + _scriptsData.setDir(this.checkedPath); _scriptsData.setType(ScriptsDataType::scripts); } else if ( Qg::getId() == "QgStaticCheck_Libs" ) { - _scriptsData.setDir(this.checkedPath + LIBS_REL_PATH); + if (this.checkedPath.isEmpty()) + { + this.checkedPath = PROJ_PATH + LIBS_REL_PATH; + } + _scriptsData.setDir(this.checkedPath); _scriptsData.setType(ScriptsDataType::libs); } @@ -101,7 +109,7 @@ class QgStaticCheck_Scripts : QgBase @param testType Checks WinCC OA scripts or libs directory @param path Path to WinCCOA project to be checked. Per default this project. */ -void main(string testType, string path = PROJ_PATH) +void main(string testType, string path = "") { if ( testType == "scripts" ) { diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl index cf733b3..32aa0d9 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl @@ -15,10 +15,13 @@ class StaticDir : QgDir { - public setDir(const string &dirPath) + public setDir(string dirPath) { dynClear(_files); dynClear(_childs); + if (!dirPath.endsWith("/") && !dirPath.endsWith("\\")) + dirPath += makeNativePath("/"); // add path delimiter on enf of direcotry + QgDir::setDirPath(dirPath); } From c4b7a3961e7be8321de45abb7c304c5872de02d6 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Mon, 8 May 2023 00:19:50 +0200 Subject: [PATCH 14/22] ctrlppcheck-suppress --- ctrlppcheck/lib/suppressions.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ctrlppcheck/lib/suppressions.cpp b/ctrlppcheck/lib/suppressions.cpp index bfb7791..1b0c350 100644 --- a/ctrlppcheck/lib/suppressions.cpp +++ b/ctrlppcheck/lib/suppressions.cpp @@ -210,8 +210,7 @@ bool Suppressions::Suppression::parseComment(std::string comment, std::string *e std::istringstream iss(comment.substr(2)); std::string word; iss >> word; - if (word != "cppcheck-suppress" && word != "cppcheck-suppress" && - word != "ctrlppcheck-suppress" && word != "ctrlppcheck-suppress") + if (word != "cppcheck-suppress" && word != "ctrlppcheck-suppress") return false; iss >> errorId; if (!iss) From 08a8bd2e3b2f79137f87101fc59517319be33b83 Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:04:09 +0200 Subject: [PATCH 15/22] Update WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl Co-authored-by: dhoegerlETM <110166248+dhoegerlETM@users.noreply.github.com> --- .../QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl index af0fea7..566be1f 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelFile/PanelFile.ctl @@ -196,7 +196,7 @@ class PanelFile if ( !mappingHasKey(map, "version") ) { - logger.warning("The panel does not contains version information, " + getFullPath()); + logger.warning("The panel does not contain version information, " + getFullPath()); return -3; } From 75453c1d9ca10a17ccd83c744945dc2cd456e133 Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:05:18 +0200 Subject: [PATCH 16/22] Update WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl Co-authored-by: dhoegerlETM <110166248+dhoegerlETM@users.noreply.github.com> --- .../libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl index 32aa0d9..2fe85cc 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/StaticDir.ctl @@ -20,7 +20,7 @@ class StaticDir : QgDir dynClear(_files); dynClear(_childs); if (!dirPath.endsWith("/") && !dirPath.endsWith("\\")) - dirPath += makeNativePath("/"); // add path delimiter on enf of direcotry + dirPath += makeNativePath("/"); // ensure trailing path delimiter QgDir::setDirPath(dirPath); } From f0832fcdd890c2df7c3833e691a433b129bf674e Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:05:48 +0200 Subject: [PATCH 17/22] Update WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl Co-authored-by: dhoegerlETM <110166248+dhoegerlETM@users.noreply.github.com> --- .../classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl index ef66e16..14978b5 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgStaticCheck/Panels/PanelCheck.ctl @@ -177,7 +177,7 @@ class PanelCheck : QgFile string newPath = uuId + ".xml"; _pnl.setPath(newPath); - newPath = PROJ_PATH + PANELS_REL_PATH + newPath; + newPath = PROJ_PATH + PANELS_REL_PATH + newPath; // copy file into current project and convert it into xml format // conversion works only with panels located in project From 92438a0aafc34e703f3b2f400f7fa56753a73c57 Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:06:21 +0200 Subject: [PATCH 18/22] Update WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl Co-authored-by: dhoegerlETM <110166248+dhoegerlETM@users.noreply.github.com> --- .../scripts/libs/classes/QualityGates/QgBase.ctl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl index c05c7eb..2ff2f5f 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgBase.ctl @@ -27,7 +27,8 @@ OaTest myTest = OaTest(); //-------------------------------------------------------------------------------- /** Error codes used in QgBase.cat */ -enum QgBaseError { +enum QgBaseError +{ Exception = 1, NotImplemented = 20, Start, From e5f20e16ac0f66e4099a006f6b680be0f9bf682c Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:08:08 +0200 Subject: [PATCH 19/22] Update WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl Co-authored-by: dhoegerlETM <110166248+dhoegerlETM@users.noreply.github.com> --- .../libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl index 27f1137..cb040b2 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl @@ -161,7 +161,7 @@ class QgCtrlppCheck : QgBase } QgFile f = QgFile(error.path); - if ( f.isExample() || f.isTest() || !f.isPatternMatch(includeFilesPattern) ) + if (f.isExample() || f.isTest() || !f.isPatternMatch(includeFilesPattern)) return true; if ( error.msg == "" ) From d91a7442b87e3e03e7d91a73b1b1e803d3bbf83c Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:17:13 +0200 Subject: [PATCH 20/22] Update variableNaming.xml --- .../data/ctrlPpCheck/rule/variableNaming.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml index fc533f8..bc8dff9 100644 --- a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml +++ b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/variableNaming.xml @@ -7,18 +7,6 @@ simple --> - - ^.+$ From 7e0023f431f7111c6ede0df9815e16a52fd4aa24 Mon Sep 17 00:00:00 2001 From: Martin Pokorny <89339813+mPokornyETM@users.noreply.github.com> Date: Sun, 14 May 2023 19:19:00 +0200 Subject: [PATCH 21/22] Delete ctrl_3.20.xml --- .../data/ctrlPpCheck/rule/ctrl_3.20.xml | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml diff --git a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml b/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml deleted file mode 100644 index 8819c76..0000000 --- a/WinCCOA_QualityChecks/data/ctrlPpCheck/rule/ctrl_3.20.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - raw - uses \"stdVar\" - - obsolete_uses_stdVar - warning - Library 'stdVar.ctl' is deprecated. Please use library std.ctl. - - - - \ No newline at end of file From 4d1ab8cb8fc723b1eaf0179e7fc3bf33423dd572 Mon Sep 17 00:00:00 2001 From: Pokorny Martin Date: Sun, 14 May 2023 19:48:00 +0200 Subject: [PATCH 22/22] load rules from DevTools/Base/rule --- .../libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl index cb040b2..61e4e2f 100644 --- a/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl +++ b/WinCCOA_QualityChecks/scripts/libs/classes/QualityGates/QgCtrlppCheck/QgCtrlppCheck.ctl @@ -136,7 +136,7 @@ class QgCtrlppCheck : QgBase // load rules check.settings.addRuleFile(getPath(DATA_REL_PATH, "ctrlPpCheck/rule/ctrl.xml")); // general - check.settings.addRuleFile(getPath(DATA_REL_PATH, "ctrlPpCheck/rule/ctrl_" + VERSION + ".xml")); // version specific + check.settings.addRuleFile(getPath(DATA_REL_PATH, "DevTools/Base/rule/ctrl_" + VERSION + ".xml")); // version specific check.settings.addRuleFile(getPath(DATA_REL_PATH, "ctrlPpCheck/rule/__proj__.xml")); // proj specific check.settings.addEnabled("all");