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
Pull Request — master (#57)
by Benjamin
01:31
created

shouldComponentUpdate.js ➔ shouldPagerUpdate   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 20
rs 9.4285
nop 2
1
import deepEqual from 'deep-equal';
2
import { getLastUpdate } from './lastUpdate';
3
4
export function shouldGridUpdate(nextProps) {
5
    let result = true;
0 ignored issues
show
Unused Code introduced by
The assignment to variable result seems to be never used. Consider removing it.
Loading history...
6
7
    const { reducerKeys, stateKey, store } = this.props;
8
9
    const nextUpdate = getLastUpdate(store, stateKey, reducerKeys);
10
11
    result = (
12
        !deepEqual(nextUpdate, this._lastUpdate)
13
        || !equalProps(nextProps, this._lastProps)
14
    );
15
16
    this._lastUpdate = nextUpdate;
17
    this._lastProps = nextProps;
18
19
    return result;
20
}
21
22
export function shouldPagerUpdate(nextProps, nextState) {
23
24
    let result = true;
0 ignored issues
show
Unused Code introduced by
The assignment to variable result seems to be never used. Consider removing it.
Loading history...
25
26
    const limitedNextProps = {
27
        gridData: nextProps.gridData,
28
        state: this.state
29
    };
30
31
    const limitedProps = {
32
        gridData: this.props.gridData,
33
        state: nextState
34
    };
35
36
    result = (
37
        !deepEqual(limitedNextProps, limitedProps)
38
    );
39
40
    return result;
41
}
42
43
export function shouldHeaderUpdate(nextProps, nextState) {
44
    let result = true;
0 ignored issues
show
Unused Code introduced by
The assignment to variable result seems to be never used. Consider removing it.
Loading history...
45
46
    const menuState = state =>
47
        state && state['header-row'];
48
49
    const limitedNextProps = {
50
        columns: nextProps.columns,
51
        menuState: menuState(nextProps.menuState),
52
        state: nextState
53
    };
54
55
    const limitedProps = {
56
        columns: this.previousColumns,
57
        menuState: menuState(this.props.menuState),
58
        state: this.state
59
    };
60
61
    result = (
62
        !deepEqual(limitedNextProps, limitedProps)
63
    );
64
65
    this.previousColumns = this.props.columns.slice();
66
67
    return result;
68
}
69
70
export function shouldRowUpdate(nextProps) {
71
    let result = true;
0 ignored issues
show
Unused Code introduced by
The assignment to variable result seems to be never used. Consider removing it.
Loading history...
72
73
    // unique key created by setData action/reducer
74
    const key = nextProps.row._key;
75
76
    const isSelected = rows => Boolean(rows && rows[key]);
77
78
    const isMenuShown = rows => Boolean(rows && rows[key]);
79
80
    const isEdited = editorState => Boolean(
81
        editorState
82
        && editorState.row
83
        && editorState.row.rowIndex === nextProps.index
84
        && editorState.row.values
85
    );
86
87
    const limitedNextProps = {
88
        columns: slimColumn(nextProps.columns),
89
        isEdited: isEdited(nextProps.editorState),
90
        currentValues: isEdited(nextProps.editorState)
91
            ? nextProps.editorState
92
            : null,
93
        isMenuShown: isMenuShown(nextProps.menuState),
94
        row: nextProps.row,
95
        index: nextProps.index,
96
        isSelected: isSelected(nextProps.selectedRows),
97
        isDragging: nextProps.isDragging
98
    };
99
100
    const limitedProps = {
101
        columns: this.previousColumns,
102
        isEdited: isEdited(this.props.editorState),
103
        currentValues: isEdited(nextProps.editorState)
104
            ? this.props.editorState
105
            : null,
106
        isMenuShown: isMenuShown(this.props.menuState),
107
        row: this.props.row,
108
        index: this.props.index,
109
        isSelected: isSelected(this.props.selectedRows),
110
        isDragging: this.props.isDragging
111
    };
112
113
    this.previousColumns = slimColumn(this.props.columns.slice());
114
115
    result = (
116
        !deepEqual(limitedNextProps, limitedProps)
117
    );
118
119
    return result;
120
}
121
122
export const slimColumn = cols =>
123
    cols.map(col => ({ hidden: col.hidden, dataIndex: col.dataIndex }));
124
125
export const equalProps = (props = {}, newProps = {}) => {
126
    return props.height === newProps.height
127
        && deepEqual(props.classNames, newProps.classNames)
128
        && deepEqual(props.events, newProps.events);
129
};
130