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.
Passed
Push — master ( abe803...75229a )
by Sebastian
02:16
created

domReady.js ➔ domReady   B

Complexity

Conditions 5
Paths 10

Size

Total Lines 57
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 38
dl 0
loc 57
rs 8.5013
c 2
b 0
f 0
cc 5
nc 10
nop 1

3 Functions

Rating   Name   Duplication   Size   Complexity  
A domReady.js ➔ ... ➔ completed 0 7 5
A domReady.js ➔ ... ➔ detach 0 9 2
A domReady.js ➔ ... ➔ scrollCheck 0 15 2

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
function domReady(fn) {
2
    'use strict';
3
4
    var ready = false;
5
6
    function detach() {
7
        if (document.addEventListener) {
8
            document.removeEventListener('DOMContentLoaded', completed);
9
            window.removeEventListener('load', completed);
10
        } else {
11
            document.detachEvent('onreadystatechange', completed);
12
            window.detachEvent('onload', completed);
13
        }
14
    }
15
16
    function completed() {
17
        if (!ready && (document.addEventListener || event.type === 'load' || document.readyState === 'complete')) {
0 ignored issues
show
Bug introduced by
The variable event seems to be never declared. If this is a global, consider adding a /** global: event */ 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...
18
            ready = true;
19
            detach();
20
            fn();
21
        }
22
    }
23
24
    if (document.readyState === 'complete') {
25
        fn();
26
    } else if (document.addEventListener) {
27
        document.addEventListener('DOMContentLoaded', completed);
28
        window.addEventListener('load', completed);
29
    } else {
30
        document.attachEvent('onreadystatechange', completed);
31
        window.attachEvent('onload', completed);
32
33
        var top = false;
0 ignored issues
show
Unused Code introduced by
The assignment to variable top seems to be never used. Consider removing it.
Loading history...
34
35
        try {
36
            top = window.frameElement == null && document.documentElement;
0 ignored issues
show
Best Practice introduced by
Comparing window.frameElement to null using the == operator is not safe. Consider using === instead.
Loading history...
37
        } catch (e) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
38
39
        if (top && top.doScroll) {
40
            (function scrollCheck() {
41
                if (ready) {
42
                    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
43
                }
44
45
                try {
46
                    top.doScroll('left');
47
                } catch (e) {
48
                    return setTimeout(scrollCheck, 50);
49
                }
50
51
                ready = true;
52
                detach();
53
                fn();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
54
            })();
55
        }
56
    }
57
}
58