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:
parent
1d5166d70c
commit
10c7c70970
2
Makefile
2
Makefile
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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->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->strAt(0) is a slow way to say tok->str()</summary>
|
||||
</message>
|
||||
</rule>
|
||||
<rule version="1">
|
||||
|
@ -36,6 +37,7 @@
|
|||
<message>
|
||||
<id>TokenMatchVariable</id>
|
||||
<severity>error</severity>
|
||||
<summary>Simplify 'Token :: Match ( expr , %var% ) && expr->variable()' to 'expr->variable()'</summary>
|
||||
<summary>Simplify 'Token :: Match ( expr , %var% ) && expr->variable()' to 'expr->variable()'</summary>
|
||||
</message>
|
||||
</rule>
|
||||
</rules>
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue