app/javascript/lib/Tree.ts
Function updateNodesPosition
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateNodesPosition() {
let top = 1;
let left = 1;
const root = this.getIndex(1);
Function build
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
build(obj: N): Tree.Index<N> {
const indexes = this.indexes;
const startId = this.cnt;
const index = { id: startId, node: obj };
Function walk
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const walk = (objs: Tree.Node[], parent: Tree.Index<N>) => {
const children: Tree.Id[] = [];
objs.forEach((obj: N) => {
const index: Tree.Index<N> = {
id: this.cnt,
Function move
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
move(fromId: Tree.Id, toId: Tree.Id, placement: MovePlacement) {
if (fromId === toId || toId === 1) {
return;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getNodeByTop
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
getNodeByTop(top: Tree.Id) {
const indexes = this.indexes;
for (const id in indexes) {
if (Object.prototype.hasOwnProperty.call(indexes, id)) {
if (indexes[id].top === top) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"