Total Complexity | 5 |
Complexity/F | 2.5 |
Lines of Code | 23 |
Function Count | 2 |
Duplicated Lines | 23 |
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 | /** |
||
8 | View Code Duplication | function findPriceSelector() |
|
|
|||
9 | { |
||
10 | var priceDOM = document.getElementById("our_price_display"); |
||
11 | if (priceDOM != null) { |
||
12 | return '#our_price_display'; |
||
13 | } else { |
||
14 | priceDOM = document.querySelector(".current-price span[itemprop=price]") |
||
15 | if (priceDOM != null) { |
||
16 | return ".current-price span[itemprop=price]"; |
||
17 | } |
||
18 | } |
||
19 | |||
20 | return 'default'; |
||
21 | } |
||
22 | |||
23 | function findQuantitySelector() |
||
24 | { |
||
25 | var quantityDOM = document.getElementById("quantity_wanted"); |
||
26 | if (quantityDOM != null) { |
||
27 | return '#quantity_wanted'; |
||
28 | } |
||
29 | return 'default'; |
||
30 | } |