Files
codeql/python/ql/src/external/MostlyDuplicateClass.qhelp
Chris Smowton 455b840712 Fix all dead qhelp links
For those documents with no obvious new home I've pointed the links to the Internet Archive.
2021-04-23 15:20:21 +01:00

32 lines
1.5 KiB
XML

<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>If two classes share a lot of code then there is a lot of unnecessary code
duplication. This makes it difficult to make changes in future and makes the classes less easy to
read.</p>
</overview>
<recommendation>
<p>While completely duplicated classes are rare, they are usually a sign of a simple oversight.
Usually the required action is to remove all but one of them. A common exception to this rule may
arise from generated code that simply occurs in several places in the source tree; the check can be
adapted to exclude such results.</p>
<p>It is far more common to see duplication of many methods between two classes, leaving just a few
that are actually different. Consider such situations carefully. Are the differences deliberate or
a result of an inconsistent update to one of the clones? If the latter, then treating the classes
as completely duplicate and eliminating one (while preserving any corrections or new features that
may have been introduced) is the best course. If the two classes serve different purposes then it
is possible there is a missing level of abstraction. Consider creating a common superclass of the
duplicate classes.</p>
</recommendation>
<references>
<li>E. Juergens, F. Deissenboeck, B. Hummel and S. Wagner, <em>Do Code Clones Matter?</em>, 2009. (<a href="https://wwwbroy.in.tum.de/~juergens/publications/ICSE2009_RP_0110_juergens.pdf">available online</a>).</li>
</references>
</qhelp>