GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

src/util/getTreePathFromId.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 21
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 5
c 1
b 0
f 0
nc 1
mnd 2
bc 4
fnc 3
dl 0
loc 21
rs 10
bpm 1.3333
cpm 1.6666
noi 1
1
export const getTreePathFromId = (flatData, id) => {
2
    const res = [];
3
    const node = flatData.find(n => n.get('_id') === id);
4
    const finder = n => n.get('_id') === lastParentId;
0 ignored issues
show
Bug introduced by
The local (let) variable lastParentId is used before it is defined. This will cause a reference error.
Loading history...
5
    let lastParentId = node.get('_id');
6
7
    while (lastParentId !== undefined) {
8
        const parent = flatData.find(finder);
9
10
        if (parent) {
11
            res.push(parent.get('_id'));
12
            lastParentId = parent.get('_parentId');
13
        }
14
15
        else {
16
            lastParentId = undefined;
17
        }
18
    }
19
20
    return res.reverse();
21
};
22