Skip to content

Commit 94240de

Browse files
committed
Fix Vera++ issues
1 parent b525e70 commit 94240de

File tree

11 files changed

+181
-146
lines changed

11 files changed

+181
-146
lines changed

plugins/robots/common/twoDModel/src/engine/constraints/details/template.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,22 @@ void XmlTemplate::processParams(const QDomElement &params)
8080
auto &&firstParamDecl = params.firstChildElement("param");
8181
while (!firstParamDecl.isNull()) {
8282
if (firstParamDecl.tagName() != "param") {
83-
addDeclarationError(QObject::tr(R"(the <params> tag can only contain the <param> tag as a child tag for template %1,
83+
addDeclarationError(QObject::tr(R"(the <params> tag can only contain
84+
the <param> tag as a child tag for template %1,
8485
actual tag is <%2>)")
85-
.arg(mId, firstParamDecl.tagName()), firstParamDecl.lineNumber(), TemplateParseErrorCode::ParamsTagContainOnlyParam);
86+
.arg(mId, firstParamDecl.tagName()), firstParamDecl.lineNumber(),
87+
TemplateParseErrorCode::ParamsTagContainOnlyParam);
8688
return;
8789
}
8890

8991
auto &&paramName = firstParamDecl.attribute("name");
9092

9193
if (paramName.isEmpty()) {
9294
addDeclarationError(QObject::tr(
93-
R"(The <param> tag of template %1 was provided, but the required "name" attribute was missing.)")
94-
.arg(mId), firstParamDecl.lineNumber(), TemplateParseErrorCode::MissingParamNameAttribute);
95+
R"(The <param> tag of template %1 was provided,
96+
but the required "name" attribute was missing.)")
97+
.arg(mId), firstParamDecl.lineNumber(),
98+
TemplateParseErrorCode::MissingParamNameAttribute);
9599
return;
96100
}
97101

@@ -144,8 +148,9 @@ void XmlTemplate::processDeclaration(const QDomElement &templateDeclaration)
144148
auto &&contentDecl = templateDeclaration.firstChildElement("content");
145149
if (contentDecl.isNull()) {
146150
addDeclarationError(QObject::tr(
147-
R"(The <template> of template %1 tag was provided, but the required child tag <content> was missing.)")
148-
.arg(mId), templateDeclaration.lineNumber(), TemplateParseErrorCode::MissingContentTag);
151+
R"(The <template> of template %1 tag was provided,
152+
but the required child tag <content> was missing.)")
153+
.arg(mId), templateDeclaration.lineNumber(), TemplateParseErrorCode::MissingContentTag);
149154
return;
150155
}
151156
processContent(contentDecl);
@@ -163,7 +168,8 @@ bool XmlTemplate::validateParam(const QDomNode &with, const QString &param)
163168
return true;
164169
}
165170

166-
void XmlTemplate::parseParams(const QDomElement &paramTag, QHash<QString, QString> &paramsForReplace, bool fromTemplate)
171+
void XmlTemplate::parseParams(const QDomElement &paramTag,
172+
QHash<QString, QString> &paramsForReplace, bool fromTemplate)
167173
{
168174
auto &&attributes = paramTag.attributes();
169175
for (int i = 0; i < attributes.length(); i++) {
@@ -221,8 +227,10 @@ QString XmlTemplate::substitute(const QDomElement &templateUsage)
221227
if (value == paramsForReplace.end()) {
222228
if (!declaredParam.mHasDefaultValue) {
223229
addSubstitutionError(
224-
QObject::tr("The parameter %1 of template %2 has no default value and was not explicitly specified by the user")
225-
.arg(*it, mId), templateUsage.lineNumber(), TemplateSubstitutionErrorCode::MissingReqiuredParam);
230+
QObject::tr("The parameter %1 of template %2 has no default"
231+
" value and was not explicitly specified by the user")
232+
.arg(*it, mId), templateUsage.lineNumber(),
233+
TemplateSubstitutionErrorCode::MissingReqiuredParam);
226234
continue;
227235
}
228236
substitute(*it, declaredParam.mDefaultValue, result);

plugins/robots/common/twoDModel/src/engine/constraints/details/template.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ namespace details {
2626

2727
/*!
2828
* \class XmlTemplate
29-
* \brief A class that describes a template and stores information about its parameters, default substitution value, substitution order, and more
29+
* \brief A class that describes a template and stores information about its parameters, default substitution value,
30+
* substitution order, and more
3031
* \inmodule twoDModel::constraints::details
3132
*
3233
* General view of template declaration:
@@ -60,7 +61,8 @@ namespace details {
6061
* The order in which parameters are defined in a template determines the order in which they are initialized.
6162
* In the example above, the nestedVariable parameter can be used in the default value for the xml_node parameter.
6263
*/
63-
class XmlTemplate {
64+
class XmlTemplate
65+
{
6466
public:
6567
XmlTemplate(const XmlTemplate&) = delete;
6668
XmlTemplate& operator=(const XmlTemplate&) = delete;
@@ -131,7 +133,8 @@ class XmlTemplate {
131133
void parseWith(const QDomElement &with, QHash<QString, QString> &paramsForReplace);
132134

133135
bool validateParam(const QDomNode &with, const QString &param);
134-
void parseParams(const QDomElement &paramTag, QHash<QString, QString> &paramsForReplace, bool fromTemplate = false);
136+
void parseParams(const QDomElement &paramTag, QHash<QString, QString>
137+
&paramsForReplace, bool fromTemplate = false);
135138
void substitute(const QString& name, const QString& value, QString &result);
136139
void clear();
137140

plugins/robots/common/twoDModel/src/engine/constraints/details/templatesParser.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,19 @@ QDomElement TemplatesParser::processTemplate(const QDomElement &elements, Expans
151151

152152
if (context.mMacrosInProgress.contains(templateName)) {
153153
substituteError(QObject::tr(
154-
"Recursive template expansion detected: %1 -> %2")
155-
.arg(context.mOrder.join(" -> "), templateName), elements. lineNumber(), context, SubstitutionErrorCode::RecursiveTemplateExpansion);
154+
"Recursive template expansion detected: %1 -> %2")
155+
.arg(context.mOrder.join(" -> "), templateName), elements.lineNumber(),
156+
context, SubstitutionErrorCode::RecursiveTemplateExpansion);
156157
return {};
157158
}
158159

159160
auto *foundTemplate = findTemplate(templateName);
160161

161162
if (!foundTemplate) {
162-
substituteError(QObject::tr(R"(The &lt;use&gt; tag contains a template=%1 attribute that is not the name of a declared template)")
163-
.arg(templateName), elements.lineNumber(), context, SubstitutionErrorCode::UseUndeclaredTemplate);
163+
substituteError(QObject::tr(R"(The &lt;use&gt; tag contains a template=%1 attribute
164+
that is not the name of a declared template)")
165+
.arg(templateName), elements.lineNumber(), context,
166+
SubstitutionErrorCode::UseUndeclaredTemplate);
164167
return {};
165168
}
166169

@@ -182,7 +185,8 @@ QDomElement TemplatesParser::processTemplate(const QDomElement &elements, Expans
182185
QObject::tr("After substituting the parameters for"
183186
" the template %1, it did not become a valid xml node").arg(templateName);
184187
if (!result.setContent(wrappedXml, &errorMessage, &errorLine)) {
185-
substituteError(QString("%1 %2").arg(message, errorMessage), errorLine, context, SubstitutionErrorCode::QtXmlParserError);
188+
substituteError(QString("%1 %2").arg(message, errorMessage), errorLine, context,
189+
SubstitutionErrorCode::QtXmlParserError);
186190
return {};
187191
}
188192

@@ -285,7 +289,8 @@ void TemplatesParser::parseError(const QString& message, int line, ParserErrorCo
285289
mParsingErrors << message + " " + QObject::tr("line %1").arg(line);
286290
}
287291

288-
void TemplatesParser::substituteError(const QString& message, int line, const ExpansionContext &context, SubstitutionErrorCode code)
292+
void TemplatesParser::substituteError(const QString& message, int line,
293+
const ExpansionContext &context, SubstitutionErrorCode code)
289294
{
290295
Q_UNUSED(code)
291296
QLOG_ERROR() << message + " " + QObject::tr("line %1").arg(line)

plugins/robots/common/twoDModel/src/engine/constraints/details/templatesParser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ class TemplatesParser
8989
return newCtx;
9090
}
9191
};
92-
virtual void substituteError(const QString& message, int line, const ExpansionContext &context, SubstitutionErrorCode code);
92+
virtual void substituteError(const QString& message, int line,
93+
const ExpansionContext &context, SubstitutionErrorCode code);
9394
private:
9495
/// It is used to parse all templates from the directory. Thus, each xml file in the directory will be examined,
9596
/// and each file will search for the top-level template or templates tag.

plugins/robots/common/twoDModel/src/engine/model/model.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void Model::deserialize(const QDomDocument &model)
194194
mChecker->parseConstraints(constraints, importedNode);
195195
}
196196
}
197-
// If something goes wrong with the template system at some point, the user can simply not use Constraint Parser directly.
197+
// If something goes wrong with the template system at some point, the user can
198+
// simply not use Constraint Parser directly.
198199
else if(templates.isNull()) {
199200
const auto &constraints = model.documentElement().firstChildElement("constraints");
200201
mChecker->parseConstraints(constraints, constraints);

0 commit comments

Comments
 (0)