mirror of
https://github.com/github/codeql.git
synced 2026-02-24 02:43:40 +01:00
29 lines
999 B
XML
29 lines
999 B
XML
<!DOCTYPE qhelp PUBLIC
|
|
"-//Semmle//qhelp//EN"
|
|
"qhelp.dtd">
|
|
<qhelp>
|
|
<overview>
|
|
<p>Very complex conditions are hard to understand and therefore are a source of a lot of defects.</p>
|
|
|
|
</overview>
|
|
<recommendation>
|
|
<p>Complex expressions can often be made easier to read by separating them into different variables
|
|
or even giving some parts of the condition their own boolean valued method. Using separate methods
|
|
both reduces code reuse and simplifies the expression.</p>
|
|
|
|
</recommendation>
|
|
<example>
|
|
<p>This example demonstrates some possible conditions and whether or not they are acceptable. As
|
|
you can see, the length of the condition is not the only thing that contributes to its complexity.
|
|
</p>
|
|
<sample src="ComplexCondition.cs" />
|
|
|
|
</example>
|
|
<references>
|
|
|
|
<li>Robert C. Martin - <em>Clean Code: A Handbook of Agile Software Craftsmanship</em>, §17.G28</li>
|
|
<li>Steve McConnell - <em>Code Complete: A Practical Handbook of Software Construction</em></li>
|
|
|
|
</references>
|
|
</qhelp>
|