Completed
Push — master ( ebbfd2...019445 )
by Jeroen De
62:46
created

app/js/lib/reducers/async_requests.js   A

Complexity

Total Complexity 11
Complexity/F 11

Size

Lines of Code 26
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 26
rs 10
c 2
b 0
f 0
wmc 11
mnd 2
bc 3
fnc 1
bpm 3
cpm 11
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
C module.exports 0 24 11
1
'use strict';
2
3
module.exports = function ( state, action ) {
4
	if ( typeof state === 'undefined' ) {
5
		state = { isValidating: false, runningValidations: 0 };
6
	}
7
	switch ( action.type ) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
8
		case 'BEGIN_BANK_DATA_VALIDATION':
9
		case 'BEGIN_EMAIL_ADDRESS_VALIDATION':
10
		case 'BEGIN_ADDRESS_VALIDATION':
11
		case 'BEGIN_PAYMENT_DATA_VALIDATION':
12
			return { isValidating: true, runningValidations: state.runningValidations + 1 };
13
		case 'FINISH_BANK_DATA_VALIDATION':
14
		case 'FINISH_EMAIL_ADDRESS_VALIDATION':
15
		case 'FINISH_ADDRESS_VALIDATION':
16
		case 'FINISH_PAYMENT_DATA_VALIDATION':
17
			if ( state.runningValidations === 0 ) {
18
				return state;
19
			}
20
			return {
21
				isValidating: state.runningValidations > 1,
22
				runningValidations: state.runningValidations - 1
23
			};
24
	}
25
	return state;
26
};
27