.code-chronicle/errors.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 18
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
mnd 1
bc 1
fnc 2
dl 0
loc 18
rs 10
bpm 0.5
cpm 1.5
noi 1
c 0
b 0
f 0
1
/* eslint-disable no-param-reassign */
2
/* eslint-disable import/no-commonjs */
3
/* eslint-disable import/unambiguous */
4
const errors = require('../lib/errors');
5
6
const Errors = Object.values(errors);
7
8
module.exports = {
9
    onSection(section) {
10
        const values = section.values[0];
11
        const errorClassName = values.name;
12
        const Error = Errors.find(e => e.name === errorClassName);
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type Error. This makes code hard to read, consider using a different name.
Loading history...
13
14
        if (Error) {
15
            const e = new Error();
16
17
            values.id = e.code;
18
            values.description = e.message;
19
        }
20
    }
21
};
22