<!DOCTYPE qhelp PUBLIC"-//Semmle//qhelp//EN""qhelp.dtd"><qhelp><overview><p>If two functions share a lot of code then there is a lot of unnecessary codeduplication. This makes it difficult to make changes in future and makes the code less easy to read.</p></overview><recommendation><p>While completely duplicated functions 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 mayarise from generated code that simply occurs in several places in the source tree; the check can beadapted to exclude such results.</p><p>It is far more common to see duplication of many lines between two functions, leaving just a fewthat are actually different. Consider such situations carefully. Are the differences deliberate or aresult of an inconsistent update to one of the clones? If the latter, then treating the functions ascompletely duplicate and eliminating one (while preserving any corrections or new features that mayhave been introduced) is the best course. If two functions serve genuinely different purposes butalmost all of their lines are the same, then consider extracting the same lines to a separate function.</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>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。