cppcheck/rules/token-matching.xml

42 lines
1.4 KiB
XML

<?xml version="1.0"?>
<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">
<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">
<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>
</message>
</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>
</message>
</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% ) &amp;&amp; expr->variable()' to 'expr->variable()'</summary>
</message>
</rule>