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 ( 25a751...9df45a )
by Benjamin
12:23
created

stateGetter.js ➔ ???   D

Complexity

Conditions 9
Paths 6

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 9
c 2
b 0
f 0
nc 6
dl 0
loc 27
rs 4.909
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
            const nestedInImmutable = typeof state.get === 'function';
16
            const nestedState = nestedInImmutable
17
                ? state.get(props.reducerKeys)
18
                : state[props.reducerKeys];
19
            return get(nestedState , key, entry);
20
        }
21
        else if (typeof props.reducerKeys === 'object'
22
            && Object.keys(props.reducerKeys).length > 0
23
            && props.reducerKeys[key]) {
24
25
            const dynamicKey = props.reducerKeys[key];
26
            return get(state, dynamicKey, entry);
27
        }
28
    }
29
30
    const val = get(state, key, entry);
31
32
    if (val) {
33
        return val;
34
    }
35
36
    return null;
37
};
38
39
export const get = (state, key, entry) => {
40
41
    if (!state) {
42
        return null;
43
    }
44
45
    const isImmutable = typeof state.get === 'function';
46
    const stateItem = isImmutable
47
        ? state.get(key)
48
        : state[key];
49
50
    if (!stateItem) {
51
        return null;
52
    }
53
54
    return stateItem.get(entry);
55
};
56