Passed
Push — master ( 7fe328...eb4ada )
by
unknown
01:39
created

src/utils/module.js   A

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 22
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 13
mnd 2
bc 2
fnc 3
dl 0
loc 22
rs 10
bpm 0.6666
cpm 1.6666
noi 2
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A module.js ➔ constructor 0 5 1
1
2
export const PeerDependency = {
3
    X : class PeerDependencyX extends Error {
0 ignored issues
show
Bug introduced by
The variable Error seems to be never initialized.
Loading history...
4
        constructor(error) {
5
            super(error.message);
6
            this.name = 'MISSING_PEER_DEPENDENCY';
7
            this.original = error;
8
        }
9
    },
10
11
    load(moduleName) {
12
        try {
13
            // eslint-disable-next-line security/detect-non-literal-require
14
            return require(moduleName);
15
        } catch (error) {
16
            return new this.X(error);
17
        }
18
    },
19
20
    check(module) {
21
        if (module instanceof this.X) throw module.original;
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...
22
    }
23
};
24