src/reporters/Base.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.2

Size

Lines of Code 28
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 16
mnd 1
bc 1
fnc 5
dl 0
loc 28
rs 10
bpm 0.2
cpm 1.2
noi 0
c 0
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A BaseReporter.constructor 0 3 1
A BaseReporter.getHash 0 3 1
A BaseReporter._init 0 1 1
A BaseReporter._build 0 13 3
1
import dP from 'dot-prop';
2
import { findGroup } from './utils';
3
4
export default class BaseReporter {
5
    constructor(file) {
6
        this.file = file;
7
    }
8
9
    _init() {}
10
11
    _build(actions, { groupBy = [] } = {}) {
12
        const map = new Map();
13
        const groups = {};
14
15
        for (const a of actions) {
16
            const groupValues = groupBy.map(key => dP.get(a, key));
17
18
            findGroup.call(this, groups, groupValues, a.id);
19
            map.set(a.id, a);
20
        }
21
22
        return { groups, map };
23
    }
24
25
    getHash(action) {
26
        return action.id;
27
    }
28
}
29