Passed
Push — master ( 238446...a1cd93 )
by Dmytro
26:52 queued 13s
created

tests/utils.js   A

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 18
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 10
mnd 2
bc 2
fnc 2
dl 0
loc 18
bpm 1
cpm 2
noi 2
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A utils.js ➔ resolve 0 3 1
A utils.js ➔ load 0 11 3
1
import path from 'path';
2
import { entry } from './constants';
3
4
export function load(relPath, clearCache) {
5
    const absPath = path.resolve(entry, relPath);
6
7
    if (clearCache) delete require.cache[require.resolve(absPath)];
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...
8
    // eslint-disable-next-line security/detect-non-literal-require
9
    const result =  require(absPath);
10
11
    if (clearCache) delete require.cache[require.resolve(absPath)];
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...
12
13
    return result;
14
}
15
16
export function resolve(relPath) {
17
    return require.resolve(path.join(entry, relPath));
18
}
19