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 ( 904d32...e60a44 )
by Cedric
01:35
created

store.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 1
c 5
b 0
f 0
nc 1
dl 0
loc 3
rs 10
ccs 1
cts 1
cp 1
nop 0
crap 1
1
class InMemoryStore {
2
3
    constructor () {
4 1
        this._store = {};
5
    }
6
7
    _recurse (key, value) {
8
9 10
        if (key === undefined) {
10 1
            return this._store;
11
        }
12
13 9
        let writeMode = value !== undefined;
14
15 9
        let currentLevel = this._store;
16 9
        let levels = key.split('.');
17
18 9
        for (let i = 0, l = levels.length; i < l; i++) {
19 19
            if (!writeMode && currentLevel[levels[i]] === undefined) {
20 1
                return null;
21
            }
22
23 18
            if (!writeMode) {
24 6
                currentLevel = currentLevel[levels[i]];
25 6
                continue;
26
            }
27
28 12
            if (currentLevel[levels[i]] === undefined) {
29 11
                currentLevel[levels[i]] = {};
30
            }
31
32 12
            if (i + 1 === l) {
33 5
                currentLevel[levels[i]] = value;
34
            }
35
36 12
            currentLevel = currentLevel[levels[i]];
37
        }
38
39 8
        return currentLevel;
40
    }
41
42
    get (key, defaultValue = null) {
43 5
        return this._recurse(key) || defaultValue;
44
    }
45
46
    set (key, value) {
47 5
        this._recurse(key, value);
48 5
        return this;
49
    }
50
51
    reset () {
52 11
        this._store = {};
53
    }
54
55
}
56
57
export default new InMemoryStore();
58