Total Complexity | 8 |
Complexity/F | 4 |
Lines of Code | 38 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* global variationSimulatorData */ |
||
3 | if (typeof variationSimulatorData == 'undefined'){ |
||
4 | throw new Error("variationSimulatorData is undefined"); |
||
5 | } |
||
6 | |||
7 | window.lastPrice = ''; |
||
8 | function updateSimulator() |
||
9 | { |
||
10 | if (window.WCSimulatorId !== '') |
||
|
|||
11 | { |
||
12 | var updateSelector = variationSimulatorData.variationSelector; |
||
13 | if (updateSelector === 'default') { |
||
14 | updateSelector = 'div.woocommerce-variation-price span.price span.woocommerce-Price-amount'; |
||
15 | } |
||
16 | |||
17 | var productType = variationSimulatorData.productType; |
||
18 | |||
19 | if (productType !=='variable') |
||
20 | { |
||
21 | clearInterval(window.variationInterval); |
||
22 | } |
||
23 | else |
||
24 | { |
||
25 | var priceDOM = document.querySelector(updateSelector); |
||
26 | if (priceDOM != null) { |
||
27 | var newPrice = priceDOM.innerText; |
||
28 | if (newPrice !== window.lastPrice) { |
||
29 | window.lastPrice = newPrice; |
||
30 | window.pgSDK.simulator.update(window.WCSimulatorId, {itemAmountSelector: updateSelector}) |
||
31 | } |
||
32 | } else { |
||
33 | return false; |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | window.variationInterval = setInterval(function () { |
||
39 | updateSimulator(); |
||
40 | }, 5000); |
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.