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 ( 3eec9f...47bd99 )
by Alex
01:51
created

sugarloaf/static/js/index.js   A

Complexity

Total Complexity 16
Complexity/F 1.23

Size

Lines of Code 118
Function Count 13

Duplication

Duplicated Lines 98
Ratio 83.05 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
dl 98
loc 118
rs 10
wmc 16
nc 1
mnd 1
bc 19
fnc 13
bpm 1.4615
cpm 1.2306
noi 6

2 Functions

Rating   Name   Duplication   Size   Complexity  
A d3.json 0 5 1
B index.js ➔ buildCharts 98 98 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
var filename_status = '/api/current',
2
    WIDTH = 300,
3
    HEIGHT = 200,
4
    MARGINS = {top: 10, left: 20, right: 20, bottom: 20},
5
    sugarloaf = {};
6
7
sugarloaf.difficulty_order = {
8
    'beginner': 1,
9
    'intermediate': 2,
10
    'black': 3,
11
    'double-black': 4,
12
    'terrain-park': 5
13
}
14
15 View Code Duplication
function buildCharts() {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
16
    sugarloaf.ndx = crossfilter(sugarloaf.data.trails);
17
18
    sugarloaf.openDim = sugarloaf.ndx.dimension(function(d) {
19
        if (d.open) {
20
            return 'Open';
21
        } else {
22
            return 'Closed';
23
        };
24
    });
25
    sugarloaf.openGroup = sugarloaf.openDim.group().reduceCount(function(d) {
26
        return d.open;
27
    });
28
    sugarloaf.openChart = dc.rowChart('#chart-row-open');
0 ignored issues
show
Bug introduced by
The variable dc seems to be never declared. If this is a global, consider adding a /** global: dc */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
29
    sugarloaf.openChart
30
        .width(WIDTH)
31
        .height(HEIGHT/2)
32
        .margins(MARGINS)
33
        .dimension(sugarloaf.openDim)
34
        .group(sugarloaf.openGroup)
35
        .elasticX(true);
36
37
38
    sugarloaf.groomedDim = sugarloaf.ndx.dimension(function(d) {
39
        if (d.groomed) {
40
            return 'Groomed';
41
        } else {
42
            return 'Ungroomed';
43
        }
44
    });
45
    sugarloaf.groomedGroup = sugarloaf.groomedDim.group().reduceCount(function(d) {
46
        return d.groomed;
47
    })
48
    sugarloaf.groomedChart = dc.rowChart('#chart-row-groomed');
0 ignored issues
show
Bug introduced by
The variable dc seems to be never declared. If this is a global, consider adding a /** global: dc */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
49
    sugarloaf.groomedChart
50
        .width(WIDTH)
51
        .height(HEIGHT/2)
52
        .margins(MARGINS)
53
        .dimension(sugarloaf.groomedDim)
54
        .group(sugarloaf.groomedGroup)
55
        .elasticX(true);
56
    
57
58
    sugarloaf.snowmakingDim = sugarloaf.ndx.dimension(function(d) {
59
        if (d.snowmaking) {
60
            return 'Snowmaking in progress';
61
        } else {
62
            return 'Not snowmaking';
63
        }
64
    });
65
    sugarloaf.snowmakingGroup = sugarloaf.snowmakingDim.group().reduceCount(function(d) {
66
        return d.snowmaking;
67
    });
68
    sugarloaf.snowmakingChart = dc.rowChart('#chart-row-snowmaking');
0 ignored issues
show
Bug introduced by
The variable dc seems to be never declared. If this is a global, consider adding a /** global: dc */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
69
    sugarloaf.snowmakingChart
70
        .width(WIDTH)
71
        .height(HEIGHT/2)
72
        .margins(MARGINS)
73
        .dimension(sugarloaf.snowmakingDim)
74
        .group(sugarloaf.snowmakingGroup)
75
        .elasticX(true);
76
77
    sugarloaf.difficultyDim = sugarloaf.ndx.dimension(function(d) {
78
        return d.difficulty;
79
    });
80
    sugarloaf.difficultyGroup = sugarloaf.difficultyDim.group().reduceCount(function(d) {
81
        return d.difficulty;
82
    });
83
    sugarloaf.difficultyChart = dc.rowChart('#chart-row-difficulty');
0 ignored issues
show
Bug introduced by
The variable dc seems to be never declared. If this is a global, consider adding a /** global: dc */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
84
    sugarloaf.difficultyChart
85
        .width(WIDTH)
86
        .height(HEIGHT)
87
        .margins(MARGINS)
88
        .dimension(sugarloaf.difficultyDim)
89
        .group(sugarloaf.difficultyGroup)
90
        .ordering(function(d) {
91
            return sugarloaf.difficulty_order[d.key];
92
        })
93
        .elasticX(true);
94
    
95
    
96
    sugarloaf.areaDim = sugarloaf.ndx.dimension(function(d) {
97
        return d.area;
98
    });
99
    sugarloaf.areaGroup = sugarloaf.areaDim.group().reduceCount(function(d) {
100
        return d.area;
101
    });
102
    sugarloaf.areaChart = dc.rowChart('#chart-row-area');
0 ignored issues
show
Bug introduced by
The variable dc seems to be never declared. If this is a global, consider adding a /** global: dc */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
103
    sugarloaf.areaChart
104
        .width(WIDTH)
105
        .height(HEIGHT * 2)
106
        .margins(MARGINS)
107
        .dimension(sugarloaf.areaDim)
108
        .group(sugarloaf.areaGroup)
109
        .elasticX(true);
110
111
    dc.renderAll();
112
}
113
114
d3.json(filename_status, function(data) {
0 ignored issues
show
Bug introduced by
The variable d3 seems to be never declared. If this is a global, consider adding a /** global: d3 */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
115
    sugarloaf.data = data;
116
117
    buildCharts();
118
});