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 ( c335e5...c6cb10 )
by Benjamin
01:46
created

src/util/stateGetter.js   A

Complexity

Total Complexity 26
Complexity/F 13

Size

Lines of Code 64
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 0
wmc 26
c 2
b 0
f 2
nc 1
mnd 2
bc 5
fnc 2
dl 0
loc 64
rs 10
bpm 2.5
cpm 13
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
* will not return immutable object, only plain JS object
7
8
* if a dynamic reducerKey is passed, it will favor that key
9
* over the build in grid keys
10
11
*/
12
13
export function stateGetter(state, props, key, entry) {
14
15
    if (props
16
        && props.reducerKeys
17
        && Object.keys(props.reducerKeys).length > 0
18
        && props.reducerKeys[key]) {
19
20
        const dynamicKey = props.reducerKeys[key];
21
22
        const dynamicState = state
23
            && state[dynamicKey]
24
            && state[dynamicKey].get
25
            && state[dynamicKey].get(entry)
26
            ? state[dynamicKey].get(entry)
27
            : null;
28
29
        return dynamicState &&
30
            dynamicState.toJS
31
            ? dynamicState.toJS()
32
            : dynamicState;
33
    }
34
35
    const firstTry = state
36
        && state[key]
37
        && state[key].get
38
        && state[key].get(entry)
39
        ? state[key].get(entry)
40
        : null;
41
42
    if (firstTry) {
43
        return firstTry.toJS ? firstTry.toJS() : firstTry;
44
    }
45
46
    const keys = Object.keys(state);
47
    const normalizedKeys = keys
48
        .map((s) => s.toLowerCase());
49
50
    const keyIndex = normalizedKeys.indexOf(key.toLowerCase());
51
52
    if (keyIndex !== -1) {
53
        const secondTry = state
54
            && state[keys[keyIndex]]
55
            && state[keys[keyIndex]].get
56
            && state[keys[keyIndex]].get(entry)
57
            ? state[keys[keyIndex]].get(entry)
58
            : null;
59
60
        if (!state[keys[keyIndex]]) {
61
            /* eslint-disable no-console */
62
            console.warn([
63
                'Case insensitivity for reducer keys will no longer',
64
                'be supported in the next major release.',
65
                'Please update your reducer keys',
66
                'to match the main exports.'
67
            ]);
68
        }
69
70
        return secondTry && secondTry.toJS
71
            ? secondTry.toJS()
72
            : secondTry;
73
    }
74
75
    return null;
76
}
77