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/components/core/LocalStorageManager.js   A
last analyzed

Size

Lines of Code 53

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 53
rs 10
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A LocalStorageManager.js ➔ ??? 0 11 2
1
import { debounce } from './../../util/throttle';
2
3
export class LocalStorageManager {
4
5
    setStateItem({ stateKey, property, value }) {
6
        const json = JSON.stringify(value);
7
8
        if (!window.localStorage) {
9
            return value;
10
        }
11
12
        window.localStorage.setItem(
13
            this.getKey({ stateKey, property }), json
14
        );
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
15
    }
16
17
    debouncedSetStateItem() {
18
        return debounce(this.setStateItem.bind(this), 500, false);
19
    }
20
21
    getStateItem({ stateKey, property, value, shouldSave = true }) {
22
23
        if (!window.localStorage) {
24
            return value;
25
        }
26
27
        const item = window.localStorage.getItem(
28
            this.getKey({ stateKey, property })
29
        );
30
31
        if (item) {
32
            return JSON.parse(item);
33
        }
34
35
        if (value && shouldSave) {
36
            this.setStateItem({ stateKey, property, value });
37
        }
38
39
        return value;
40
    }
41
42
    getKey({ stateKey, property }) {
43
44
        if (!stateKey || !property) {
45
            throw new Error('stateKey and property are required params');
46
        }
47
48
        return `react-grid-${stateKey}-${property}`;
49
    }
50
51
}
52
53
export default new LocalStorageManager();
54