mirror of
https://github.com/github/codeql.git
synced 2026-01-14 15:04:56 +01:00
32 lines
1.2 KiB
XML
32 lines
1.2 KiB
XML
<!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>
|