Completed
Push — master ( 3d5932...e9e92d )
by Felipe
01:35
created

example.js ➔ ... ➔ $(document).ready   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 116

Duplication

Lines 0
Ratio 0 %

Importance

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

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
define(['jquery', 'lodash', 'ig_markerfactory'], function (jQuery, _, MarkerFactory) {
2
3
	console.debug('jQuery is', jQuery, 'MarkerFactory is', MarkerFactory);
4
5
	jQuery(document).ready(function () {
6
7
		var icons_fontello = {
0 ignored issues
show
Coding Style introduced by
As per coding-style, prefer block-scoped variables using let or const which have better semantics than var.

Since ECMAScript 6, you can create block-scoped vars or constants with the keywords let or const. These variables/constants are only valid in the code block where they have been declared.

Consider the following two pieces of code:

if (true)
 {
    var x = "Hello, Stonehenge!";
}

console.log(x); //prints Hello, Stonehenge! to the console

and

if (true)
 {
    let x = "Hello, Stonehenge!";
}

console.log(x); //ReferenceError: x is not defined

The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.

To know more about this ECMA6 feature, look at the MDN pages on let and const.

Loading history...
8
				camera: MarkerFactory.autoIcon({
9
					label: 'e810',
10
					font: 'fontello',
11
					color: '#CC0000',
12
					fontsize: 20,
13
					scale: 0.8
14
				}),
15
				retail: MarkerFactory.autoIcon({
16
					label: 'e896',
17
					font: 'fontello',
18
					color: '#33CCCC',
19
					fontsize: 20,
20
					scale: 0.8
21
				}),
22
				plane: MarkerFactory.autoIcon({
23
					label: 'e892',
24
					font: 'fontello',
25
					color: '#CC00FF',
26
					fontsize: 20,
27
					scale: 0.8
28
				}),
29
				taxi: MarkerFactory.autoIcon({
30
					label: 'e88c',
31
					font: 'fontello',
32
					color: '#33CC33',
33
					fontsize: 20,
34
					scale: 0.8
35
				})
36
			},
37
			icons_fontawesome = {
38
				camera: MarkerFactory.autoIcon({
39
					label: 'f030',
40
					font: 'FontAwesome',
41
					color: '#CC0000',
42
					fontsize: 20,
43
					scale: 0.8
44
				}),
45
				retail: MarkerFactory.autoIcon({
46
					label: 'f07a',
47
					font: 'FontAwesome',
48
					color: '#33CCCC',
49
					fontsize: 20,
50
					scale: 0.8
51
				}),
52
				plane: MarkerFactory.autoIcon({
53
					label: 'f072',
54
					font: 'FontAwesome',
55
					color: '#CC00FF',
56
					fontsize: 20,
57
					scale: 0.8
58
				}),
59
				taxi: MarkerFactory.autoIcon({
60
					label: 'f1ba',
61
					font: 'FontAwesome',
62
					color: '#33CC33',
63
					fontsize: 20,
64
					scale: 0.8
65
				})
66
			},
67
			icons_material = {
68
				camera: MarkerFactory.autoIcon({
69
					label: 'E3B0',
70
					font: 'Material Icons',
71
					color: '#CC0000',
72
					fontsize: 20,
73
					scale: 0.8
74
				}),
75
				retail: MarkerFactory.autoIcon({
76
					label: 'E8CC',
77
					font: 'Material Icons',
78
					color: '#33CCCC',
79
					fontsize: 20,
80
					scale: 0.8
81
				}),
82
				plane: MarkerFactory.autoIcon({
83
					label: 'E195',
84
					font: 'Material Icons',
85
					color: '#CC00FF',
86
					fontsize: 20,
87
					scale: 0.8
88
				}),
89
				taxi: MarkerFactory.autoIcon({
90
					label: 'e531',
91
					font: 'Material Icons',
92
					color: '#33CC33',
93
					fontsize: 20,
94
					scale: 0.8
95
				})
96
			};
97
98
99
		_.each(icons_fontello, function (icon, name) {
100
			var theimage = jQuery('<img>');
0 ignored issues
show
Coding Style introduced by
As per coding-style, prefer block-scoped variables using let or const which have better semantics than var.

Since ECMAScript 6, you can create block-scoped vars or constants with the keywords let or const. These variables/constants are only valid in the code block where they have been declared.

Consider the following two pieces of code:

if (true)
 {
    var x = "Hello, Stonehenge!";
}

console.log(x); //prints Hello, Stonehenge! to the console

and

if (true)
 {
    let x = "Hello, Stonehenge!";
}

console.log(x); //ReferenceError: x is not defined

The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.

To know more about this ECMA6 feature, look at the MDN pages on let and const.

Loading history...
101
			theimage.attr('src', icon.url);
102
			jQuery('#fontello').find('.' + name).append(theimage);
103
		});
104
105
		_.each(icons_fontawesome, function (icon, name) {
106
			var theimage = jQuery('<img>');
0 ignored issues
show
Coding Style introduced by
As per coding-style, prefer block-scoped variables using let or const which have better semantics than var.

Since ECMAScript 6, you can create block-scoped vars or constants with the keywords let or const. These variables/constants are only valid in the code block where they have been declared.

Consider the following two pieces of code:

if (true)
 {
    var x = "Hello, Stonehenge!";
}

console.log(x); //prints Hello, Stonehenge! to the console

and

if (true)
 {
    let x = "Hello, Stonehenge!";
}

console.log(x); //ReferenceError: x is not defined

The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.

To know more about this ECMA6 feature, look at the MDN pages on let and const.

Loading history...
107
			theimage.attr('src', icon.url);
108
			jQuery('#fontawesome').find('.' + name).append(theimage);
109
		});
110
111
		_.each(icons_material, function (icon, name) {
112
			var theimage = jQuery('<img>');
0 ignored issues
show
Coding Style introduced by
As per coding-style, prefer block-scoped variables using let or const which have better semantics than var.

Since ECMAScript 6, you can create block-scoped vars or constants with the keywords let or const. These variables/constants are only valid in the code block where they have been declared.

Consider the following two pieces of code:

if (true)
 {
    var x = "Hello, Stonehenge!";
}

console.log(x); //prints Hello, Stonehenge! to the console

and

if (true)
 {
    let x = "Hello, Stonehenge!";
}

console.log(x); //ReferenceError: x is not defined

The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.

To know more about this ECMA6 feature, look at the MDN pages on let and const.

Loading history...
113
			theimage.attr('src', icon.url);
114
			jQuery('#materialicons').find('.' + name).append(theimage);
115
		});
116
117
118
119
120
	});
121
122
123
});
124