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 ( 137f54...278f6d )
by Florian
01:11
created

Storage.parseLines   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 19
rs 9.4285

2 Functions

Rating   Name   Duplication   Size   Complexity  
A 0 3 1
A 0 7 2
1
/*jslint
2
  regexp: true,
3
  indent: 4
4
*/
5
6
/*global
7
  Cookies,
8
  App, Conversion, Coordinates,
9
  alpha2id
10
*/
11
12
var Storage = {};
13
14
15
Storage.set = function (key, value) {
16
    'use strict';
17
18
    Cookies.set(key, value, {expires: 30});
19
};
20
21
22
Storage.getString = function (key, default_value) {
23
    'use strict';
24
25
    var s = Cookies.get(key);
26
    if (s !== undefined) {
27
        return s;
28
    }
29
30
    return default_value;
31
};
32
33
34
Storage.getInt = function (key, default_value) {
35
    'use strict';
36
37
    var s = Cookies.get(key);
38
    if (s !== undefined) {
39
        return parseInt(s, 10);
40
    }
41
42
    return default_value;
43
};
44
45
46
Storage.getFloat = function (key, default_value) {
47
    'use strict';
48
49
    var s = Cookies.get(key);
50
    if (s !== undefined) {
51
        return parseFloat(s);
52
    }
53
54
    return default_value;
55
};
56
57
58
Storage.parseMarkers = function () {
59
    'use strict';
60
61
    var raw_ids = Storage.getString('markers', null);
62
63
    if (!raw_ids) {
64
        return [];
65
    }
66
67
    return raw_ids.split(':').map(function (id_string) {
68
        var m = {id: null, name: null, coords: null, r: 0, color: ""},
69
            raw_data,
70
            data;
71
72
        m.id = Conversion.getInteger(id_string, 0, 26 * 10);
73
        if (m.id === null) {
74
            return null;
75
        }
76
77
        raw_data = Cookies.get('marker' + m.id);
78
        if (!raw_data) {
79
            return null;
80
        }
81
82
        data = raw_data.split(':');
83
        if (data.length !== 4 && data.length !== 5) {
84
            return null;
85
        }
86
87
        m.coords = Coordinates.toLatLng(parseFloat(data[0]), parseFloat(data[1]));
88
        if (!m.coords) {
89
            return null;
90
        }
91
92
        m.r = App.repairRadius(parseFloat(data[2]), 0);
93
94
        if ((/^([a-zA-Z0-9\-_]*)$/).test(data[3])) {
95
            m.name = data[3];
96
        }
97
98
        if (data.length === 5 && (/^([a-fA-F0-9]{6})$/).test(data[4])) {
99
            m.color = data[4];
100
        }
101
102
        return m;
103
    }).filter(function (thing) {
104
        return (thing !== null);
105
    });
106
};
107
108
109
Storage.parseLines = function () {
110
    'use strict';
111
112
    var raw_lines = Storage.getString('lines', null);
113
114
    if (!raw_lines) {
115
        return [];
116
    }
117
118
    return raw_lines.split('*').map(function (pair_string) {
119
        var pair = pair_string.split(':');
120
        if (pair.length === 2) {
121
            return {source: alpha2id(pair[0]), target: alpha2id(pair[1])};
122
        }
123
        return null;
124
    }).filter(function (thing) {
125
        return (thing !== null);
126
    });
127
};
128