-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathComplexCondition.qhelp
More file actions
43 lines (29 loc) · 1.04 KB
/
ComplexCondition.qhelp
File metadata and controls
43 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!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>