Activated 'make validateRules' and improved rule XML file parsing. Now, it optionally accepts '<rules>...</rules>' tags to make xmllint happy.

This commit is contained in:
orbitcowboy 2022-06-22 00:03:18 +02:00
parent 1d5166d70c
commit 10c7c70970
4 changed files with 31 additions and 27 deletions

View File

@ -389,7 +389,7 @@ checkCWEEntries: /tmp/errorlist.xml
$(PYTHON_INTERPRETER) tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml
.PHONY: validateRules
validateRules:
#xmllint --noout rules/*.xml
xmllint --noout rules/*.xml
###### Build

View File

@ -713,6 +713,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
tinyxml2::XMLDocument doc;
if (doc.LoadFile(12+argv[i]) == tinyxml2::XML_SUCCESS) {
tinyxml2::XMLElement *node = doc.FirstChildElement();
if (node && strcmp(node->Value(), "rules") == 0)
node = node->NextSiblingElement("rules");
for (; node && strcmp(node->Value(), "rule") == 0; node = node->NextSiblingElement()) {
Settings::Rule rule;

View File

@ -1,4 +1,5 @@
<?xml version="1.0"?>
<rules>
<rule version="1">
<pattern>Token :: (?:findm|(?:simple|)M)atch \([^,]+,\s+"(?:\s+|[^"]+?\s+")</pattern>
<message>
@ -20,7 +21,7 @@
<message>
<id>TokentokAt0</id>
<severity>error</severity>
<summary>tok->tokAt(0) is a slow way to say tok.</summary>
<summary>tok-&gt;tokAt(0) is a slow way to say tok.</summary>
</message>
</rule>
<rule version="1">
@ -28,7 +29,7 @@
<message>
<id>TokenstrAt0</id>
<severity>error</severity>
<summary>tok->strAt(0) is a slow way to say tok->str()</summary>
<summary>tok-&gt;strAt(0) is a slow way to say tok-&gt;str()</summary>
</message>
</rule>
<rule version="1">
@ -36,6 +37,7 @@
<message>
<id>TokenMatchVariable</id>
<severity>error</severity>
<summary>Simplify 'Token :: Match ( expr , %var% ) &amp;&amp; expr->variable()' to 'expr->variable()'</summary>
<summary>Simplify 'Token :: Match ( expr , %var% ) &amp;&amp; expr-&gt;variable()' to 'expr-&gt;variable()'</summary>
</message>
</rule>
</rules>

View File

@ -503,7 +503,7 @@ int main(int argc, char **argv)
fout << "\t$(PYTHON_INTERPRETER) tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml\n";
fout << ".PHONY: validateRules\n";
fout << "validateRules:\n";
fout << "\t#xmllint --noout rules/*.xml\n";
fout << "\txmllint --noout rules/*.xml\n";
fout << "\n###### Build\n\n";