Total Complexity | 3 |
Complexity/F | 3 |
Lines of Code | 12 |
Function Count | 1 |
Duplicated Lines | 12 |
Ratio | 100 % |
Changes | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | /* |
||
11 | View Code Duplication | (function () { |
|
|
|||
12 | var pre = document.getElementsByTagName('pre'), |
||
13 | preLen = pre.length; |
||
14 | for (var i = 0; i < preLen; i++) { |
||
15 | pre[i].innerHTML = '<span class="line-number"></span>' + pre[i].innerHTML + '<span class="clear-both"></span>'; |
||
16 | var linesNum = pre[i].innerHTML.split(/\n/).length; |
||
17 | for (var number = 0; number < linesNum; number++) { |
||
18 | var lineNumber = pre[i].getElementsByTagName('span')[0]; |
||
19 | lineNumber.innerHTML += '<span>' + (number + 1) + '</span>'; |
||
20 | } |
||
21 | } |
||
22 | })(); |