Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup me #40

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions WinCCOA_QualityChecks/msg/de_AT.utf8/QgBase.cat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
00001,QualityGates does not run successfully !!!
00010,Assertion return error: $1
00011,Assertion works: $1
00012,Assertion return an acceptable error (known bug): $1
00020,The function $1 is not implemented.
00021,Start quality gate $1.
00022,Calculate sources for quality gate $1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ assert.function.NLOC,NLOC (No. Lines Of Code)
reason.function.NLOC,The function '$function.name()' has invalid lines of code ($function.NLOC)
assert.function.countOfLines,Count of lines
reason.function.countOfLines,The function '$function.name()' has invalid count of lines ($function.countOfLines)
assert.function.paramCount,Count of parameters
assert.function.paramCount,The function '$function.name()' has $function.paramCount parameter(s)
reason.function.paramCount,The function '$function.name()' has too much parameters ($function.paramCount)
1 change: 1 addition & 0 deletions WinCCOA_QualityChecks/msg/en_US.utf8/QgBase.cat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
00001,QualityGates does not run successfully !!!
00010,Assertion return error: $1
00011,Assertion works: $1
00012,Assertion return an acceptable error (known bug): $1
mPokornyETM marked this conversation as resolved.
Show resolved Hide resolved
00020,The function $1 is not implemented.
00021,Start quality gate $1.
00022,Calculate sources for quality gate $1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@


#uses "classes/FileSys/QgDir"
#uses "classes/QualityGates/AddOn/FileSys/QgAddOnSourceDir"
#uses "classes/QualityGates/Qg"
#uses "classes/QualityGates/QgApp"
#uses "classes/QualityGates/AddOn/FileSys/QgAddOnSourceDir"
#uses "classes/QualityGates/QgTest"

class QgAddOnResultsDir
{
Expand Down Expand Up @@ -102,13 +103,15 @@ class QgAddOnResultsDir
{
if (_resultDir == "")
{
if (!Qg::isRunningOnJenkins())
if (!QgTest::isStartedByTestFramework())
{
// projPath should be used, when Jenkins is not used
// When you start some locale tests, proj path will be used
_resultDir = makeNativePath(PROJ_PATH + DATA_REL_PATH + "QualityGates/" + _qgId + "/" + _buildNo + "/");
}
else
{
/// FIXME (mpokorny) currently I does not see any reason for this code.
mPokornyETM marked this conversation as resolved.
Show resolved Hide resolved
/// probably can be remove
QgApp app = QgApp::getAppFromProjName(PROJ);
_resultDir = makeNativePath(app.getSourcePath() + "QgResult/" + Qg::getId() + "/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*
* @details Base utilitys to handle with QualityGate.
* @author lschopp
* @todo check it, but I think (mPokorny), that it can be removed. It looks like
mPokornyETM marked this conversation as resolved.
Show resolved Hide resolved
* old store-code (because of wording like backend ...)
*/
class Qg
{
Expand Down Expand Up @@ -71,12 +73,6 @@ class Qg
return dynContains(getAllIds(), getId());
}

//------------------------------------------------------------------------------
public static bool isRunningOnJenkins()
{
return (getenv("WORKSPACE") != "");
}

//--------------------------------------------------------------------------------
//@private members
//--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class QgAddOnResultErr
return map;
}



//--------------------------------------------------------------------------------
//@private members
//--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

#uses "CtrlPv2Admin"

//---------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
/**
@todo try to remove this class. After many discussion it looks like old
store-code and has nothing to do with this tool
*/
class QgApp
{
//-------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------
public QgApp(string id = "")
{
_isValid = FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// used libraries (#uses)
#uses "classes/ErrorHdl/OaLogger"
#uses "classes/QualityGates/AddOn/FileSys/QgAddOnTmpSourceDir"
#uses "classes/QualityGates/QgBaseError"
#uses "classes/QualityGates/QgResultPublisher"
#uses "classes/oaTest/OaTest"
#uses "classes/QualityGates/Qg"
Expand All @@ -23,7 +24,6 @@
QgMsgCat myQgMsgCat = QgMsgCat();
OaTest myTest = OaTest();


//--------------------------------------------------------------------------------
/** Error codes used in QgBase.cat
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//--------------------------------------------------------------------------------
/** Error codes used in QgBase.cat
*/
enum QgBaseError
{
Exception = 1,
/// Assertion return error: $1
AssertionError = 10,
/// Assertion works: $1
AssertionOK,
AssertionErrorAccepted,
NotImplemented = 20,
Start,
Calculate,
Validate,
Done
};
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,20 @@ class QgOverloadedFilesCheck

if (isAllowed(relPath))
{
assertion.setAssertionText("assert.isOverloadedAllowed", makeMapping("file.name", relPath));
assertion.setReasonText("reason.isOverloadedAllowed", makeMapping("file.name", relPath,
"file.isOverloadedFrom", overloadedFrom));
const mapping dollars = makeMapping("file.name", relPath,
"file.isOverloadedFrom", overloadedFrom);
assertion.setAssertionText("assert.isOverloadedAllowed", dollars);
assertion.setReasonText("reason.isOverloadedAllowed", dollars);
assertion.allowNextErr(TRUE);
assertion.assertFalse(overloadedFrom != "", settings.getScorePoints()); // negative logic, for better look in store
assertion.referenceValue = (overloadedFrom != ""); // reference value faken, for better look in store
}
else
{
assertion.setAssertionText("assert.isOverloaded", makeMapping("file.name", relPath));
assertion.setReasonText("reason.isOverloaded", makeMapping("file.name", relPath,
"file.isOverloadedFrom", overloadedFrom));
const mapping dollars = makeMapping("file.name", relPath,
"file.isOverloadedFrom", overloadedFrom);
assertion.setAssertionText("assert.isOverloaded", dollars);
assertion.setReasonText("reason.isOverloaded", dollars);
assertion.assertFalse(overloadedFrom != "", settings.getScorePoints()); // negative logic, for better look in store

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//

#uses "classes/QualityGates/Qg"
#uses "classes/QualityGates/QgTest"
#uses "classes/QualityGates/AddOn/FileSys/QgAddOnResultsDir"
#uses "classes/QualityGates/QgVersionResult"

Expand Down Expand Up @@ -93,13 +94,7 @@ class QgResultPublisher
//------------------------------------------------------------------------------
protected int _publishState(const QgAddOnResultsDir &resDir)
{
string resPath;

if (Qg::isRunningOnJenkins())
resPath = resDir.getDirPath() + "_state";
else
resPath = resDir.getDirPath() + "State";

const string resPath = resDir.getDirPath() + "State";
file f = fopen(resPath, "wb+");

if (ferror(f))
Expand All @@ -113,13 +108,7 @@ class QgResultPublisher
//------------------------------------------------------------------------------
protected int _publishSummary(const QgAddOnResultsDir &resDir)
{
string resPath;

if (Qg::isRunningOnJenkins())
resPath = resDir.getDirPath() + "_data";
else
resPath = resDir.getDirPath() + "sum.json";

const string resPath = resDir.getDirPath() + "sum.json";
file f = fopen(resPath, "wb+");

if (ferror(f))
Expand All @@ -133,7 +122,7 @@ class QgResultPublisher
//------------------------------------------------------------------------------
protected int _publishFull(const QgAddOnResultsDir &resDir)
{
if (Qg::isRunningOnJenkins() || true)
if (QgTest::isStartedByTestFramework())
return _publishFullOnJenkins(resDir);
else
return _publishFullLocale(resDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ class FunctionData
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_FunctionData");

assertion.setAssertionText("assert.function.CCN");
assertion.setReasonText("reason.function.CCN", makeMapping("function.name", getName(),
"function.CCN", getCCN()));
const mapping dollars = makeMapping("function.name", getName(),
"function.CCN", getCCN());
assertion.setAssertionText("assert.function.CCN", dollars);
assertion.setReasonText("reason.function.CCN", dollars);
assertion.assertLessEqual(getCCN(),
settings.getHighLimit(DEFAULT_CNN_HIGH),
settings.getScorePoints());
Expand All @@ -154,9 +155,10 @@ class FunctionData
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_FunctionData");

assertion.setAssertionText("assert.function.NLOC");
assertion.setReasonText("reason.function.NLOC", makeMapping("function.name", getName(),
"function.NLOC", getNLOC()));
const mapping dollars = makeMapping("function.name", getName(),
"function.NLOC", getNLOC());
assertion.setAssertionText("assert.function.NLOC", dollars);
assertion.setReasonText("reason.function.NLOC", dollars);

assertion.assertBetween(getNLOC(),
settings.getLowLimit(DEFAULT_NLOC_LOW),
Expand All @@ -176,9 +178,10 @@ class FunctionData
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_FunctionData");

assertion.setAssertionText("assert.function.paramCount");
assertion.setReasonText("reason.function.paramCount", makeMapping("function.name", getName(),
"function.paramCount", getNLOC()));
const mapping dollars = makeMapping("function.name", getName(),
"function.paramCount", getNLOC());
assertion.setAssertionText("assert.function.paramCount", dollars);
assertion.setReasonText("reason.function.paramCount", dollars);
assertion.assertLessEqual(getParamCount(),
settings.getHighLimit(10),
settings.getScorePoints());
Expand All @@ -196,9 +199,10 @@ class FunctionData
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_FunctionData");

assertion.setAssertionText("assert.function.countOfLines");
assertion.setReasonText("reason.function.countOfLines", makeMapping("function.name", getName(),
"function.countOfLines", getLinesCount()));
const mapping dollars = makeMapping("function.name", getName(),
"function.countOfLines", getLinesCount());
assertion.setAssertionText("assert.function.countOfLines", dollars);
assertion.setReasonText("reason.function.countOfLines", dollars);
assertion.info(getLinesCount(), settings.getScorePoints());
result.addChild(assertion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ class ScriptData
// ognore all not calculated files (crypted, empty files ...)
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptData");
assertion.setAssertionText("assert.script.isCalculated");
assertion.setReasonText("reason.script.isCalculated", makeMapping("script.name", getName()));
const mapping dollars = makeMapping("script.name", getName());
assertion.setAssertionText("assert.script.isCalculated", dollars);
assertion.setReasonText("reason.script.isCalculated", dollars);

if (!assertion.assertTrue(isCalculated(), settings.getScorePoints()))
{
Expand Down Expand Up @@ -396,9 +397,10 @@ class ScriptData
// check count of functions.
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptData");
assertion.setAssertionText("assert.script.countOfFunctions");
assertion.setReasonText("reason.script.countOfFunctions", makeMapping("script.name", getName(),
"countOfFunctions", getCountOfFunctions()));
const mapping dollars = makeMapping("script.name", getName(),
"countOfFunctions", getCountOfFunctions());
assertion.setAssertionText("assert.script.countOfFunctions", dollars);
assertion.setReasonText("reason.script.countOfFunctions", dollars);
assertion.assertBetween(getCountOfFunctions(), getMinCountOfFunctions(), getMaxCountOfFunctions(), settings.getScorePoints());
result.addChild(assertion);
}
Expand All @@ -419,9 +421,10 @@ class ScriptData
{
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptData");
assertion.setAssertionText("assert.script.avgCCN");
assertion.setReasonText("reason.script.avgCCN", makeMapping("script.name", getName(),
"avgCCN", getAvgCCN()));
const mapping dollars = makeMapping("script.name", getName(),
"avgCCN", getAvgCCN());
assertion.setAssertionText("assert.script.avgCCN", dollars);
assertion.setReasonText("reason.script.avgCCN", dollars);
assertion.assertLessEqual(getAvgCCN(), getMaxAvgCCN(), settings.getScorePoints());
result.addChild(assertion);
}
Expand All @@ -441,9 +444,10 @@ class ScriptData
{
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptData");
assertion.setAssertionText("assert.script.NLOC");
assertion.setReasonText("reason.script.NLOC", makeMapping("script.name", getName(),
"NLOC", getNLOC()));
const mapping dollars = makeMapping("script.name", getName(),
"NLOC", getNLOC());
assertion.setAssertionText("assert.script.NLOC", dollars);
assertion.setReasonText("reason.script.NLOC", dollars);
assertion.assertBetween(getNLOC(), getMinNLOC(), getMaxNLOC(), settings.getScorePoints());
result.addChild(assertion);
}
Expand All @@ -464,9 +468,10 @@ class ScriptData
{
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptData");
assertion.setAssertionText("assert.script.avgNLOC");
assertion.setReasonText("reason.script.avgNLOC", makeMapping("script.name", getName(),
"avgNLOC", getAvgNLOC()));
const mapping dollars = makeMapping("script.name", getName(),
"avgNLOC", getAvgNLOC());
assertion.setAssertionText("assert.script.avgNLOC", dollars);
assertion.setReasonText("reason.script.avgNLOC", dollars);
assertion.info(getAvgNLOC(), settings.getScorePoints()); // does not check it, only information character
// assertion.assertLessEqual(getAvgNLOC(), getMaxAvgCCN());
result.addChild(assertion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class ScriptFile : QgFile
// ignore all example files, the example are terrible scripts
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptFile");
assertion.setAssertionText("assert.file.isExampleFile");
assertion.setReasonText("reason.file.isExampleFile", makeMapping("file.name", getName()));
const mapping dollars = makeMapping("file.name", getName());
assertion.setAssertionText("assert.file.isExampleFile", dollars);
assertion.setReasonText("reason.file.isExampleFile", dollars);
assertion.allowNextErr(TRUE);

if (!assertion.assertFalse(this.isExample(), settings.getScorePoints()))
Expand All @@ -125,9 +126,10 @@ class ScriptFile : QgFile
// check for valid extensions
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptFile");
assertion.setAssertionText("assert.file.extension");
assertion.setReasonText("reason.file.extension", makeMapping("file.name", getName(),
"file.extension", _extension));
const mapping dollars = makeMapping("file.name", getName(),
"file.extension", _extension);
assertion.setAssertionText("assert.file.extension", dollars);
assertion.setReasonText("reason.file.extension", dollars);

if (!assertion.assertDynContains(settings.getReferenceValues(), strtolower(_extension), settings.getScorePoints()))
{
Expand All @@ -148,8 +150,9 @@ class ScriptFile : QgFile
// ognore all not calculated files (crypted, empty files ...)
shared_ptr <QgVersionResult> assertion = new QgVersionResult();
assertion.setMsgCatName("QgStaticCheck_ScriptFile");
assertion.setAssertionText("assert.file.isCalculated");
assertion.setReasonText("reason.file.isCalculated", makeMapping("file.name", getName()));
const mapping dollars = makeMapping("file.name", getName());
assertion.setAssertionText("assert.file.isCalculated", dollars);
assertion.setReasonText("reason.file.isCalculated", dollars);

if (!assertion.assertTrue(isCalculated(), settings.getScorePoints()))
{
Expand Down
Loading