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.
Passed
Push — master ( a462af...a9df0b )
by Benjamin
01:56
created

src/util/lastUpdate.js   A

Complexity

Total Complexity 14
Complexity/F 2.8

Size

Lines of Code 65
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 14
c 1
b 0
f 0
nc 1
mnd 2
bc 7
fnc 5
dl 0
loc 65
rs 10
bpm 1.4
cpm 2.8
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A lastUpdate.js ➔ ??? 0 1 1
1
let num = 0;
2
3
const REDUCER_KEYS = {
4
    BulkActions: 'bulkaction',
5
    DataSource: 'dataSource',
6
    Editor: 'editor',
7
    ErrorHandler: 'errorhandler',
8
    Grid: 'grid',
9
    Loader: 'loader',
10
    Menu: 'menu',
11
    Pager: 'pager',
12
    Selection: 'selection'
13
};
14
15
export const generateLastUpdate = () => ++num;
16
17
export const resetLastUpdate = () => { num = 0; };
18
19
export const getLastUpdate = (store, key, reducerKeys = REDUCER_KEYS) => {
20
21
    if (typeof reducerKeys === 'string') {
22
        const state = store.getState().get
23
            ? store.getState().get(reducerKeys)
24
            : store.getState()[reducerKeys];
25
26
        return updateGetter(
27
            state,
28
            REDUCER_KEYS,
29
            Object.keys(REDUCER_KEYS),
30
            key
31
        );
32
    }
33
34
    else if (typeof reducerKeys === 'object'
35
        && Object.keys(reducerKeys).length > 0) {
36
        return updateGetter(
37
            store.getState(),
38
            reducerKeys,
39
            Object.keys(REDUCER_KEYS),
40
            key
41
        );
42
    }
43
44
    return updateGetter(
45
        store.getState(),
46
        REDUCER_KEYS,
47
        Object.keys(REDUCER_KEYS),
48
        key
49
    );
50
};
51
52
export const updateGetter = (state, reducerKeys, keys, key) =>
53
    keys.reduce((prev, reducerAccessor) => {
54
        const reducerKey = reducerKeys[reducerAccessor];
55
        const stateMap = (typeof state.get === 'function')
56
            ? state.get(reducerKey)
57
            : state[reducerKey];
58
        if (stateMap && stateMap.toJS) {
59
            prev[reducerKey] = stateMap.getIn([key, 'lastUpdate']);
60
        }
61
        else if (typeof stateMap === 'object' && stateMap[key]) {
62
            prev[reducerKey] = stateMap[key].lastUpdate;
63
        }
64
        return prev;
65
    }, {});
66