-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathDuplicateBlock.qhelp
31 lines (24 loc) · 1.22 KB
/
DuplicateBlock.qhelp
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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Blocks of code that are duplicated verbatim in several places in the code are candidates for
refactoring into functions. The severity of this anti-pattern is higher for longer blocks than for short blocks.</p>
</overview>
<recommendation>
<p>Code duplication is undesirable for a range of reasons: The artificially
inflated amount of code hinders comprehension, and ranges of similar but subtly different lines
can mask the real purpose or intention behind a function. There's also a risk of
update anomalies, where only one of several copies of the code is updated to address a defect or
add a feature.</p>
<p>In the case of code block duplication, how to address the issue depends on the blocks of code themselves.
It may be possible to extract the block of code into its own function and call that instead of duplicating the code.</p>
</recommendation>
<references>
<li>Elmar Juergens, Florian Deissenboeck, Benjamin Hummel, and Stefan Wagner. 2009.
Do code clones matter? In <em>Proceedings of the 31st International Conference on
Software Engineering</em> (ICSE '09). IEEE Computer Society, Washington, DC, USA,
485-495.</li>
</references>
</qhelp>