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,41 +1,43 @@
|
|||
<?xml version="1.0"?>
|
||||
<rule version="1">
|
||||
<rules>
|
||||
<rule version="1">
|
||||
<pattern>Token :: (?:findm|(?:simple|)M)atch \([^,]+,\s+"(?:\s+|[^"]+?\s+")</pattern>
|
||||
<message>
|
||||
<id>TokenMatchSpacing</id>
|
||||
<severity>style</severity>
|
||||
<summary>Useless extra spacing for Token::*Match.</summary>
|
||||
</message>
|
||||
</rule>
|
||||
<rule version="1">
|
||||
</rule>
|
||||
<rule version="1">
|
||||
<pattern>(?U)Token :: Match \([^,]+,\s+"[^%|!\[\]]+" \)</pattern>
|
||||
<message>
|
||||
<id>UseTokensimpleMatch</id>
|
||||
<severity>error</severity>
|
||||
<summary>Token::simpleMatch should be used to match tokens without special pattern requirements.</summary>
|
||||
</message>
|
||||
</rule>
|
||||
<rule version="1">
|
||||
</rule>
|
||||
<rule version="1">
|
||||
<pattern>\b[\w_]+ \. tokAt \( 0 \)</pattern>
|
||||
<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">
|
||||
</rule>
|
||||
<rule version="1">
|
||||
<pattern>\b[\w_]+ \. strAt \( 0 \)</pattern>
|
||||
<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">
|
||||
</rule>
|
||||
<rule version="1">
|
||||
<pattern><![CDATA[Token :: Match \( (\b\w+\b) , \"%var%\" \) && (\b\1\b) \. variable \( \)]]></pattern>
|
||||
<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>
|
||||
</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