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.
Completed
Push — master ( 6efc01...f24beb )
by Benjamin
33s
created

src/util/moveTreeNode.js   A

Complexity

Total Complexity 4
Complexity/F 4

Size

Lines of Code 44
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 4
c 1
b 0
f 0
nc 1
mnd 1
bc 3
fnc 1
dl 0
loc 44
rs 10
bpm 3
cpm 4
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B moveTreeNode.js ➔ ??? 0 42 4
1
import { findTreeNode } from './findTreeNode';
2
3
export const moveTreeNode = (
4
    treeData,
5
    currentIndex,
6
    currentPath,
7
    nextIndex,
8
    nextPath,
9
    childIdentifier = 'children',
10
    rootIdentifier = 'root'
11
) => {
12
    const currentParent = findTreeNode(
13
        treeData,
14
        currentPath,
15
        childIdentifier,
16
        rootIdentifier
17
    );
18
19
    const nextParent = findTreeNode(
20
        treeData,
21
        nextPath,
22
        childIdentifier,
23
        rootIdentifier
24
    );
25
26
    if (!currentParent || !nextParent) {
27
        return treeData;
28
    }
29
30
    const node = currentParent[childIdentifier].splice(
31
        currentIndex,
32
        1
33
    )[0];
34
35
    if (!Array.isArray(nextParent[childIdentifier])) {
36
        nextParent[childIdentifier] = [];
37
    }
38
39
    nextParent[childIdentifier].splice(nextIndex, 0, node);
40
41
    node.parentId = nextPath[nextPath.length - 1];
42
43
    return treeData;
44
};
45