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 ( 414922...a9bc98 )
by butschster
12:35
created

resources/assets/js/components/events.js   A

Complexity

Total Complexity 8
Complexity/F 2

Size

Lines of Code 28
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 128
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 8
mnd 1
bc 4
fnc 4
bpm 1
cpm 2
noi 2

3 Functions

Rating   Name   Duplication   Size   Complexity  
A module.exports.fire 0 4 3
A module.exports.off 0 6 3
A module.exports.on 0 3 1
1
module.exports = function () {
2
    var events = {}, empty = [];
3
4
    return {
5
        /**
6
         *  On: listen to events
7
         */
8
        on: function (type, func, ctx) {
9
            (events[type] = events[type] || []).push([func, ctx])
10
        },
11
        /**
12
         *  Off: stop listening to event / specific callback
13
         */
14
        off: function (type, func) {
15
            type || (events = {})
16
            var list = events[type] || empty,
17
                i = list.length = func ? list.length : 0;
18
            while (i--) func == list[i][0] && list.splice(i, 1)
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...
19
        },
20
        /**
21
         * Emit: send event, callbacks will be triggered
22
         */
23
        fire: function (type) {
24
            var e = events[type] || empty, list = e.length > 0 ? e.slice(0, e.length) : e, i = 0, j;
25
            while (j = list[i++]) j[0].apply(j[1], empty.slice.call(arguments, 1))
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...
26
        }
27
    }
28
}()