Passed
Push — master ( 850f91...109844 )
by Alberto
04:39 queued 02:29
created

lib/io/EntityC.js   A

Complexity

Total Complexity 5
Complexity/F 5

Size

Lines of Code 16
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 14
mnd 4
bc 4
fnc 1
dl 0
loc 16
bpm 4
cpm 5
noi 4
c 0
b 0
f 0
rs 10
1
"use strict";
2
var __importStar = (this && this.__importStar) || function (mod) {
3
    if (mod && mod.__esModule) return mod;
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...
4
    var result = {};
5
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
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...
Best Practice introduced by
Comparing mod to null using the != operator is not safe. Consider using !== instead.
Loading history...
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
6
    result["default"] = mod;
7
    return result;
8
};
9
Object.defineProperty(exports, "__esModule", { value: true });
10
var t = __importStar(require("io-ts"));
11
var NonEmptyString_1 = require("io-ts-types/lib/NonEmptyString");
12
var IdentifierC_1 = require("./IdentifierC");
13
exports.EntityC = t.type({
14
    _type: NonEmptyString_1.NonEmptyString,
15
    _id: IdentifierC_1.IdentifierC
16
});
17