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 (#6)
by Cedric
01:37
created

src/model/store.js   A

Size

Lines of Code 55

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 55
ccs 20
cts 20
cp 1
rs 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A store.js ➔ ??? 0 3 1
1
class InMemoryStore {
2
3
    constructor () {
4 1
        this._store = {};
5
    }
6
7
    _recurse (key, value) {
8
9 8
        if (key === undefined) {
10 1
            return this._store;
11
        }
12
13 7
        let writeMode = value !== undefined;
14
15 7
        let currentLevel = this._store;
16 7
        let levels = key.split('.');
17
18 7
        for (let i = 0, l = levels.length; i < l; i++) {
19 13
            if (!writeMode && currentLevel[levels[i]] === undefined) {
20 1
                return null;
21
            }
22
23 12
            if (writeMode) {
24 6
                if (currentLevel[levels[i]] === undefined) {
25 6
                    currentLevel[levels[i]] = {};
26
                }
27
28 6
                if (i + 1 === l) {
29 3
                    currentLevel[levels[i]] = value;
30
                }
31
            }
32
33
34 12
            currentLevel = currentLevel[levels[i]];
35
        }
36
37 6
        return currentLevel;
38
    }
39
40
    get (key, defaultValue = null) {
41 5
        return this._recurse(key) || defaultValue;
42
    }
43
44
    set (key, value) {
45 3
        this._recurse(key, value);
46 3
        return this;
47
    }
48
49
    reset () {
50 10
        this._store = {};
51
    }
52
53
}
54
55
export default new InMemoryStore();
56