Passed
Pull Request — master (#59)
by Raúl
04:04
created

pagantis/views/js/simulator.js   A

Complexity

Total Complexity 5
Complexity/F 2.5

Size

Lines of Code 23
Function Count 2

Duplication

Duplicated Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 23
loc 23
rs 10
wmc 5
mnd 3
bc 3
fnc 2
bpm 1.5
cpm 2.5
noi 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A simulator.js ➔ findQuantitySelector 8 8 2

How to fix   Duplicated Code   

Duplicated Code

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
/**
2
* This file is part of the official Pagantis module for PrestaShop.
3
*
4
* @author    Pagantis <[email protected]>
5
* @copyright 2015-2016 Pagantis
6
* @license   proprietary
7
*/
8 View Code Duplication
function findPriceSelector()
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9
{
10
    var priceDOM = document.getElementById("our_price_display");
11
    if (priceDOM != null) {
0 ignored issues
show
Best Practice introduced by
Comparing priceDOM to null using the != operator is not safe. Consider using !== instead.
Loading history...
12
        return '#our_price_display';
13
    } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
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) {
0 ignored issues
show
Best Practice introduced by
Comparing quantityDOM to null using the != operator is not safe. Consider using !== instead.
Loading history...
27
        return '#quantity_wanted';
28
    }
29
    return 'default';
30
}