GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( dcbf46...b87973 )
by Benjamin
02:05
created

stateGetter.js ➔ ???   C

Complexity

Conditions 8
Paths 6

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 8
c 3
b 0
f 0
nc 6
dl 0
loc 25
rs 5.3846
nop 4
1
/*
2
* central function to retrieve state from reducer
3
* used inside of mapStateToProps by grid and other plugins
4
* @returns {object} state
5
6
* if a dynamic reducerKey is passed, it will favor that key
7
* over the build in grid keys
8
9
*/
10
11
export const stateGetter = (state, props, key, entry) => {
12
13
    if (props && props.reducerKeys) {
14
        if (typeof props.reducerKeys === 'string') {
15
            return get(state[props.reducerKeys], key, entry);
16
        }
17
        else if (typeof props.reducerKeys === 'object' &&
18
          Object.keys(props.reducerKeys).length > 0 &&
19
          props.reducerKeys[key]) {
20
21
            const dynamicKey = props.reducerKeys[key];
22
            const dynamicState = get(state, dynamicKey, entry);
23
24
            return dynamicState;
25
        }
26
    }
27
28
    const val = get(state, key, entry);
29
30
    if (val) {
31
        return val;
32
    }
33
34
    return null;
35
};
36
37
export const get = (state, key, entry) => {
38
39
    if (!state) {
40
        return null;
41
    }
42
43
    const isImmutable = typeof state.get === 'function';
44
    const stateItem = isImmutable
45
        ? state.get(key)
46
        : state[key];
47
48
    if (!stateItem) {
49
        return null;
50
    }
51
52
    return stateItem.get(entry);
53
};
54