CountryFlags.js   A
last analyzed

Complexity

Total Complexity 18
Complexity/F 2

Size

Lines of Code 43
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
wmc 18
nc 2
mnd 2
bc 13
fnc 9
dl 0
loc 43
rs 10
bpm 1.4443
cpm 2
noi 3
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A VRS.globalDispatch.hook 0 17 2
A ➔ customFormatCountryFlagImageHtml 0 13 3
A ➔ customPipeSeparatedCode 0 9 4
1
/** global: VRS */
2
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
3
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
0 ignored issues
show
Unused Code introduced by
The parameter bootStrap is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
4
            if(VRS.renderPropertyHandlers) {
5
                VRS.renderPropertyHandlers[VRS.RenderProperty.Country] = new VRS.RenderPropertyHandler({
6
                    property:               VRS.RenderProperty.Country,
7
                    surfaces:               VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
8
                    headingKey:             'ListCountry',
9
                    labelKey:               'Country',
10
                    sortableField:          VRS.AircraftListSortableField.Country,
11
                    suppressLabelCallback:  function() { return true; },
12
                    fixedWidth:             function() { return '27px'; },
13
                    hasChangedCallback:     function(aircraft) { return aircraft.country.chg; },
14
                    renderCallback:         function(aircraft) { return customFormatCountryFlagImageHtml(aircraft); },
15
                    tooltipChangedCallback: function(aircraft) { return aircraft.country.chg; },
16
                    tooltipCallback:        function(aircraft) { return aircraft.country.val; }
17
                });                
18
            }
19
        });
20
    }
21
    
22
function customFormatCountryFlagImageHtml(aircraft)
23
    {
24
        var result = '';
25
        if(aircraft.country.val) {
26
            var codeToUse = '';
27
            codeToUse = aircraft.country.val;
28
            //Place images on 'country' folder
29
            result = '<img src="images/web-country/Wdth-27/Hght-20';
30
            if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
31
            result += '/' + encodeURIComponent(codeToUse) +'.bmp" width="27px" height="20px" />';
32
        }
33
        return result;
34
    }
35
    
36
function customPipeSeparatedCode(text, code)
37
    {
38
        var result = text;
39
        if(code && code.length) {
40
            if(result.length) result += '|';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
41
            result += code;
42
        }
43
        return result;
44
    }
45