src/redux-reducer-map.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1.75

Size

Lines of Code 23
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 23
rs 10
wmc 7
mnd 3
bc 6
fnc 4
bpm 1.5
cpm 1.75
noi 2
1
const defaultOnUnknownActionTypeHandler = (state, action) => {
0 ignored issues
show
Unused Code introduced by
The constant defaultOnUnknownActionTypeHandler seems to be never used. Consider removing it.
Loading history...
2
  const error = new Error('Unknown action type ' + action.type)
3
  error.state = state
4
  error.action = action
5
  throw error
6
}
7
8
const createReducerViaMap = (map, initial, onUnknownActionType = defaultOnUnknownActionTypeHandler) =>
9
  (state, action) => {
10
    if (typeof state === 'undefined') {
11
      return initial
12
    } else if (map.hasOwnProperty(action.type)) {
13
      return map[action.type](state, action)
14
    } else if (action.type === '@@redux/INIT') {
15
      return initial
16
    } else {
17
      return onUnknownActionType(state, action)
18
    }
19
  }
20
21
createReducerViaMap.justReturnState = (state, action) => state
0 ignored issues
show
Unused Code introduced by
The parameter action is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
22
23
export default createReducerViaMap
24