mirror of
https://github.com/github/codeql.git
synced 2026-04-07 08:04:03 +02:00
44 lines
1.0 KiB
XML
44 lines
1.0 KiB
XML
<!DOCTYPE qhelp PUBLIC
|
|
"-//Semmle//qhelp//EN"
|
|
"qhelp.dtd">
|
|
<qhelp>
|
|
|
|
|
|
<overview>
|
|
<p>
|
|
This rule finds boolean expressions that have more than 5 consecutive operators that are not of the same type (e.g. alternating <code>&&</code> and <code>||</code> operators).
|
|
Long chains of operators of the same type are not flagged as violations of this rule.
|
|
</p>
|
|
|
|
<p>
|
|
Complex boolean expressions are hard to read. Consequently, when modifying such expressions
|
|
there is an increased risk of introducing defects.
|
|
Naming intermediate results as local variables will make the logic easier to read and understand.
|
|
</p>
|
|
|
|
</overview>
|
|
<recommendation>
|
|
<p>Use local variables or macros to represent intermediate values to make the condition easier to understand.</p>
|
|
|
|
</recommendation>
|
|
<example><sample src="ComplexCondition.cpp" />
|
|
|
|
|
|
</example>
|
|
<references>
|
|
|
|
<li>
|
|
<a href="http://www.cplusplus.com/doc/tutorial/operators/">Operators</a>
|
|
</li>
|
|
<li>
|
|
<a href="http://geosoft.no/development/cppstyle.html#Conditionals">Conditionals</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</references>
|
|
</qhelp>
|