-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathEmptyBlock.qhelp
More file actions
23 lines (21 loc) · 1023 Bytes
/
EmptyBlock.qhelp
File metadata and controls
23 lines (21 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Empty blocks or blocks with only code that has been commented out should be reviewed. It is
common to find commented-out code in an empty block. Commented-out code is discouraged because it
is a source of defects and maintainability issues.</p>
</overview>
<recommendation>
<p>The appropriate solution depends on the exact situation. If the block should be doing something,
add an implementation (where possible). If the block is redundant, remove it. Note that some
refactoring may then be required: for example, if the "then" branch of an if is empty, it should be
removed, and the sense of the condition of the if should be inverted to simplify the code.</p>
</recommendation>
<example>
<p>In this example the entire 'then' block of the <code>if</code> statement has been commented out.
The block should be removed and the sense of the <code>if</code> condition inverted.</p>
<sample src="EmptyBlock.cs" />
</example>
</qhelp>