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.

src/util/stateGetter.js   A
last analyzed

Complexity

Total Complexity 14
Complexity/F 7

Size

Lines of Code 46
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
wmc 14
c 2
b 0
f 0
nc 1
mnd 3
bc 8
fnc 2
dl 0
loc 46
rs 10
bpm 4
cpm 7
noi 0
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
    const isStateImmutable = typeof stateItem.get === 'function';
55
    return isStateImmutable ? stateItem.get(entry) : stateItem[entry];
56
};
57