modules/homefinder/widgets/homefinder-widgets.js   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
B hf_data.forEach 0 31 3
1
(function () {
2
	hf_data.forEach(function(data, index) {
0 ignored issues
show
Bug introduced by
The variable hf_data seems to be never declared. If this is a global, consider adding a /** global: hf_data */ 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...
3
		if ( data.type === 'directory' ) {
4
			var widget = new HomeFinder.Widgets.AdvertiserDirectory({
0 ignored issues
show
Unused Code introduced by
The variable widget seems to be never used. Consider removing it.
Loading history...
Bug introduced by
The variable HomeFinder seems to be never declared. If this is a global, consider adding a /** global: HomeFinder */ 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...
5
				container: 'directoryPreview-' + index,
6
				data: {
7
					profileName: data.affiliate,
8
					maxCount: data.count
9
				}
10
			});
11
		} else if ( data.type === 'search' ) {
12
			var widget = new HomeFinder.Widgets.Search({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable widget already seems to be declared on line 4. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
13
				container: 'searchPreview-' + index,
14
				data: {
15
					affiliate: { name: data.affiliate },
16
					area: { city: data.primary_city, state: data.primary_state },
17
					nearbyAreas: [
18
						{ city: data.nearby_city_1, state: data.nearby_state_1 },
19
						{ city: data.nearby_city_2, state: data.nearby_state_2 },
20
						{ city: data.nearby_city_3, state: data.nearby_state_3 },
21
						{ city: data.nearby_city_4, state: data.nearby_state_4 }
22
					]
23
				}
24
			});
25
		} else {
26
			var hfWidget = [{
27
				type: data.type,
28
				container: data.container + '-' + index
29
			}];
30
			HomeFinder.widgetLoader.getWidgets( hfWidget );
31
		}
32
	});
33
})();
34