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

index.js ➔ buildCharts   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 98

Duplication

Lines 98
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 98
loc 98
rs 8.3352
nc 1
nop 0

7 Functions

Rating   Name   Duplication   Size   Complexity  
A index.js ➔ ... ➔ sugarloaf.groomedDim.reduceCount 3 3 1
A index.js ➔ ... ➔ sugarloaf.difficultyDim.reduceCount 3 3 1
A index.js ➔ ... ➔ sugarloaf.difficultyChart.ordering 3 3 1
A index.js ➔ ... ➔ sugarloaf.openDim.reduceCount 3 3 1
A index.js ➔ ... ➔ sugarloaf.ndx.dimension 7 7 2
A index.js ➔ ... ➔ sugarloaf.areaDim.reduceCount 3 3 1
A index.js ➔ ... ➔ sugarloaf.snowmakingDim.reduceCount 3 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
});