Test Setup Failed
Push — master ( ae6bbc...554531 )
by
unknown
04:38
created

components-loader-mock.js ➔ define   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 84

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
dl 0
loc 84
rs 8.7169
c 1
b 0
f 0
nop 1

6 Functions

Rating   Name   Duplication   Size   Complexity  
A components-loader-mock.js ➔ ... ➔ ComponentExtendNoNeedA 0 3 1
A components-loader-mock.js ➔ ... ➔ ComponentNeedsA 0 3 1
A components-loader-mock.js ➔ ... ➔ ComponentNeedsB 0 3 1
A components-loader-mock.js ➔ ... ➔ 0 7 1
A components-loader-mock.js ➔ ... ➔ ComponentNeedsCE 0 3 1
A components-loader-mock.js ➔ ... ➔ ComponentNoNeeds 0 3 1

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
define(function(require) {
2
    'use strict';
3
4
    var $ = require('jquery');
5
    var BaseComponent = require('oroui/js/app/components/base/component');
6
7
    var ComponentNeedsB = BaseComponent.extend({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable ComponentNeedsB already seems to be declared on line 15. 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...
8
        relatedSiblingComponents: {
9
            componentB: 'component-b'
10
        },
11
12
        /**
13
         * @inheritDoc
14
         */
15
        constructor: function ComponentNeedsB() {
16
            ComponentNeedsB.__super__.constructor.apply(this, arguments);
17
        }
18
    });
19
20
    var ComponentNeedsCE = BaseComponent.extend({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable ComponentNeedsCE already seems to be declared on line 29. 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...
21
        relatedSiblingComponents: {
22
            componentC: 'component-c',
23
            componentE: 'component-e'
24
        },
25
26
        /**
27
         * @inheritDoc
28
         */
29
        constructor: function ComponentNeedsCE() {
30
            ComponentNeedsCE.__super__.constructor.apply(this, arguments);
31
        }
32
    });
33
34
    var ComponentNeedsA = BaseComponent.extend({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable ComponentNeedsA already seems to be declared on line 42. 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...
35
        relatedSiblingComponents: {
36
            componentA: 'component-a'
37
        },
38
39
        /**
40
         * @inheritDoc
41
         */
42
        constructor: function ComponentNeedsA() {
43
            ComponentNeedsA.__super__.constructor.apply(this, arguments);
44
        }
45
    });
46
47
    var ComponentExtendNoNeedA = ComponentNeedsA.extend({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable ComponentExtendNoNeedA already seems to be declared on line 55. 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...
48
        relatedSiblingComponents: {
49
            componentA: false
50
        },
51
52
        /**
53
         * @inheritDoc
54
         */
55
        constructor: function ComponentExtendNoNeedA() {
56
            ComponentExtendNoNeedA.__super__.constructor.apply(this, arguments);
57
        }
58
    });
59
60
    var ComponentNoNeeds = BaseComponent.extend({
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable ComponentNoNeeds already seems to be declared on line 64. 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...
61
        /**
62
         * @inheritDoc
63
         */
64
        constructor: function ComponentNoNeeds() {
65
            ComponentNoNeeds.__super__.constructor.apply(this, arguments);
66
        }
67
    });
68
69
    var components = {
70
        'js/needs-b-component': ComponentNeedsB,
71
        'js/needs-ce-component': ComponentNeedsCE,
72
        'js/needs-a-component': ComponentNeedsA,
73
        'js/extend-no-need-a-component': ComponentExtendNoNeedA,
74
        'js/no-needs-component': ComponentNoNeeds
75
    };
76
77
    return function(moduleName) {
78
        var deferred = $.Deferred();
79
        setTimeout(function() {
80
            deferred.resolve(components[moduleName]);
81
        }, 0);
82
        return deferred.promise();
83
    };
84
});
85