public/js/scripts.js   A
last analyzed

Complexity

Total Complexity 8
Complexity/F 2

Size

Lines of Code 51
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 32
c 0
b 0
f 0
dl 0
loc 51
rs 10
wmc 8
mnd 4
bc 4
fnc 4
bpm 1
cpm 2
noi 2
1
/*!
2
    * Start Bootstrap - Grayscale v6.0.1 (https://startbootstrap.com/themes/grayscale)
3
    * Copyright 2013-2020 Start Bootstrap
4
    * Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap-grayscale/blob/master/LICENSE)
5
    */
6
    (function ($) {
7
    "use strict"; // Start of use strict
8
9
    // Smooth scrolling using jQuery easing
10
    $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
11
        if (
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if location.pathname.replac...stname == this.hostname is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
12
            location.pathname.replace(/^\//, "") ==
13
                this.pathname.replace(/^\//, "") &&
14
            location.hostname == this.hostname
15
        ) {
16
            var target = $(this.hash);
17
            target = target.length
18
                ? target
19
                : $("[name=" + this.hash.slice(1) + "]");
20
            if (target.length) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if target.length is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
21
                $("html, body").animate(
22
                    {
23
                        scrollTop: target.offset().top - 70,
24
                    },
25
                    1000,
26
                    "easeInOutExpo"
27
                );
28
                return false;
29
            }
30
        }
31
    });
32
33
    // Closes responsive menu when a scroll trigger link is clicked
34
    $(".js-scroll-trigger").click(function () {
35
        $(".navbar-collapse").collapse("hide");
36
    });
37
38
    // Activate scrollspy to add active class to navbar items on scroll
39
    $("body").scrollspy({
40
        target: "#mainNav",
41
        offset: 100,
42
    });
43
44
    // Collapse Navbar
45
    var navbarCollapse = function () {
46
        if ($("#mainNav").offset().top > 100) {
47
            $("#mainNav").addClass("navbar-shrink");
48
        } else {
49
            $("#mainNav").removeClass("navbar-shrink");
50
        }
51
    };
52
    // Collapse now if page is not at top
53
    navbarCollapse();
54
    // Collapse the navbar when page is scrolled
55
    $(window).scroll(navbarCollapse);
56
})(jQuery); // End of use strict
57