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/lib/utils.js   A
last analyzed

Complexity

Total Complexity 13
Complexity/F 2.6

Size

Lines of Code 49
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 13
c 1
b 0
f 0
nc 1
mnd 1
bc 9
fnc 5
dl 0
loc 49
ccs 21
cts 21
cp 1
crap 0
rs 10
bpm 1.8
cpm 2.6
noi 0
1 39
export const isInt = (val) => !isNaN(val)
2
    && (
3
        Number.isInteger(val)
4
        || (typeof val === 'string' && '' + parseInt(val, 10) === val)
5
    );
6
7
8 26
export const isFloat = (val) => !isNaN(val)
9
    && !isInt(val)
10
    && val.toString().length > 0;
11
12 64
export const isColor = (val) => /^#?[0-9A-F]{6}$/i.test(val);
13
14 1
export const autoCast = (value) => {
15 56
    if (!value) {
16 2
        return value;
17
    }
18
19 54
    if (isColor(value)) {
20 34
        return ('#' + value).replace('##', '#');
21
    }
22
23 20
    if (isInt(value)) {
24 4
        return parseInt(value, 10);
25
    }
26
27 16
    if (isFloat(value)) {
28 6
        return parseFloat(value);
29
    }
30
31 10
    if (value.toLowerCase() === 'true') {
32 3
        return true;
33
    }
34
35 7
    if (value.toLowerCase() === 'false') {
36 2
        return false;
37
    }
38
39 5
    return value;
40
};
41
42
43 1
export const castString = (str) => {
44 103
    if (typeof str !== 'string' && !(str instanceof String)) {
45 4
        str = '' + str;
46
    }
47
48 103
    return str.toLowerCase();
49
};
50