Function _condenseHierarchy
has a Cognitive Complexity of 146 (exceeds 5 allowed). Consider refactoring. Open
_condenseHierarchy() {
// Global var in this scope to define when the movement has stopped.
let stillShifting = false;
let branches = {};
// first we have some methods to help shifting trees around.
- 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
File LayoutEngine.js
has 1087 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
/**
* There's a mix-up with terms in the code. Following are the formal definitions:
*
* tree - a strict hierarchical network, i.e. every node has at most one parent
Function _condenseHierarchy
has 268 lines of code (exceeds 25 allowed). Consider refactoring. Open
_condenseHierarchy() {
// Global var in this scope to define when the movement has stopped.
let stillShifting = false;
let branches = {};
// first we have some methods to help shifting trees around.
Function adaptAllOptionsForHierarchicalLayout
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
adaptAllOptionsForHierarchicalLayout(allOptions) {
if (this.options.hierarchical.enabled === true) {
let backupPhysics = this.optionsBackup.physics;
// set the physics
- 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 layoutNetwork
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
layoutNetwork() {
if (this.options.hierarchical.enabled !== true && this.options.improvedLayout === true) {
let indices = this.body.nodeIndices;
// first check if we should Kamada Kawai to layout. The threshold is if less than half of the visible
- 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 setupHierarchicalLayout
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
setupHierarchicalLayout() {
if (this.options.hierarchical.enabled === true && this.body.nodeIndices.length > 0) {
// get the size of the largest hubs and check if the user has defined a level for a node.
let node, nodeId;
let definedLevel = false;
- 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 _crawlNetwork
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
_crawlNetwork(callback = function() {}, startingNodeId) {
let progress = {};
let crawler = (node, tree) => {
if (progress[node.id] === undefined) {
- 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 minimizeEdgeLength
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
let minimizeEdgeLength = (iterations, node) => {
//window.CALLBACKS.push(() => {
// console.log("ts",node.id);
let nodeId = node.id;
let allEdges = node.edges;
LayoutEngine
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class LayoutEngine {
/**
* @param {Object} body
*/
constructor(body) {
Function setOptions
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
setOptions(options, allOptions) {
if (options !== undefined) {
let hierarchical = this.options.hierarchical;
let prevHierarchicalState = hierarchical.enabled;
util.selectiveDeepExtend(["randomSeed", "improvedLayout"],this.options, options);
- 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 layoutNetwork
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
layoutNetwork() {
if (this.options.hierarchical.enabled !== true && this.options.improvedLayout === true) {
let indices = this.body.nodeIndices;
// first check if we should Kamada Kawai to layout. The threshold is if less than half of the visible
Function _findCommonParent
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
_findCommonParent(childA,childB) {
let parents = {};
let iterateParents = (parents,child) => {
let parentRef = this.hierarchical.parentReference[child];
if (parentRef !== undefined) {
- 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 adaptAllOptionsForHierarchicalLayout
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
adaptAllOptionsForHierarchicalLayout(allOptions) {
if (this.options.hierarchical.enabled === true) {
let backupPhysics = this.optionsBackup.physics;
// set the physics
Function _getSpaceAroundNode
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
_getSpaceAroundNode(node, map) {
let useMap = true;
if (map === undefined) {
useMap = false;
}
- 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 _placeNodesByHierarchy
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_placeNodesByHierarchy(distribution) {
this.positionedNodes = {};
// start placing all the level 0 nodes first. Then recursively position their branches.
for (let level in distribution) {
if (distribution.hasOwnProperty(level)) {
- 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 setupHierarchicalLayout
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
setupHierarchicalLayout() {
if (this.options.hierarchical.enabled === true && this.body.nodeIndices.length > 0) {
// get the size of the largest hubs and check if the user has defined a level for a node.
let node, nodeId;
let definedLevel = false;
Function _crawlNetwork
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
_crawlNetwork(callback = function() {}, startingNodeId) {
let progress = {};
let crawler = (node, tree) => {
if (progress[node.id] === undefined) {
Function _centerParent
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
_centerParent(node) {
if (this.hierarchical.parentReference[node.id]) {
let parents = this.hierarchical.parentReference[node.id];
for (var i = 0; i < parents.length; i++) {
let parentId = parents[i];
- 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 setMinLevelToZero
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
setMinLevelToZero(nodes) {
let minLevel = 1e9;
// get the minimum level
for (let nodeId in nodes) {
if (nodes.hasOwnProperty(nodeId)) {
- 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 setOptions
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
setOptions(options, allOptions) {
if (options !== undefined) {
let hierarchical = this.options.hierarchical;
let prevHierarchicalState = hierarchical.enabled;
util.selectiveDeepExtend(["randomSeed", "improvedLayout"],this.options, options);
Function getMaxLevel
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
getMaxLevel(nodeId) {
let accumulator = {};
let _getMaxLevel = (nodeId) => {
if (accumulator[nodeId] !== undefined) {
- 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 _getSpaceAroundNode
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getSpaceAroundNode(node, map) {
let useMap = true;
if (map === undefined) {
useMap = false;
}
Function branchShiftCallback
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
let branchShiftCallback = (node1, node2, centerParent = false) => {
//window.CALLBACKS.push(() => {
let pos1 = this.direction.getPosition(node1);
let pos2 = this.direction.getPosition(node2);
let diffAbs = Math.abs(pos2 - pos1);
Function _placeBranchNodes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_placeBranchNodes(parentId, parentLevel) {
let childRef = this.hierarchical.childrenReference[parentId];
// if this is not a parent, cancel the placing. This can happen with multiple parents to one child.
if (childRef === undefined) {
Function _findCommonParent
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_findCommonParent(childA,childB) {
let parents = {};
let iterateParents = (parents,child) => {
let parentRef = this.hierarchical.parentReference[child];
if (parentRef !== undefined) {
Function _placeBranchNodes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_placeBranchNodes(parentId, parentLevel) {
let childRef = this.hierarchical.childrenReference[parentId];
// if this is not a parent, cancel the placing. This can happen with multiple parents to one child.
if (childRef === undefined) {
- 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 _determineLevelsDirected
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_determineLevelsDirected() {
let minLevel = 10000;
/**
* Check if there is an edge going the opposite direction for given edge
- 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 _getDistribution
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_getDistribution() {
let distribution = {};
let nodeId, node;
// we fix Y because the hierarchy is vertical,
- 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 positionInitially
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
positionInitially(nodesArray) {
if (this.options.hierarchical.enabled !== true) {
this.randomSeed = this.initialRandomSeed;
let radius = nodesArray.length + 50;
for (let i = 0; i < nodesArray.length; i++) {
- 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
Avoid deeply nested control flow statements. Open
if (handledNodeCount > 0) {
pos = this.direction.getPosition(nodeArray[i-1]) + spacing;
}
Function hasSameParent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
hasSameParent(node1, node2) {
let parents1 = this.parentReference[node1.id];
let parents2 = this.parentReference[node2.id];
if (parents1 === undefined || parents2 === undefined) {
return false;
- 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
Avoid deeply nested control flow statements. Open
if (level % 3 === 0) {
this.body.modules.clustering.clusterBridges(clusterOptions);
}
else {
this.body.modules.clustering.clusterOutliers(clusterOptions);
Function _declusterAll
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_declusterAll() {
let clustersPresent = true;
while (clustersPresent === true) {
clustersPresent = false;
for (let i = 0; i < this.body.nodeIndices.length; i++) {
- 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
Avoid deeply nested control flow statements. Open
if (before == after && level % 3 !== 0) {
this._declusterAll();
this.body.emitter.emit("_layoutFailed");
console.info("This network could not be positioned by this version of the improved layout algorithm."
+ " Please disable improvedLayout for better performance.");
Function _shiftBlock
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_shiftBlock(parentId, diff) {
let progress = {};
let shifter = (parentId) => {
if (progress[parentId]) {
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 getTreeSize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getTreeSize(nodes, index) {
let min_x = 1e9;
let max_x = -1e9;
let min_y = 1e9;
let max_y = -1e9;
- 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
TODO found Open
let clusterThreshold = 150; // TODO add this to options
- Exclude checks
TODO found Open
* TODO: Determine if this feature is needed at all
- Exclude checks
TODO found Open
// TODO: this should come from options.
- Exclude checks
TODO found Open
* TODO: Never entered; find a test case to test this!
- Exclude checks
TODO found Open
// TODO: this is options merging; see if the standard routines can be used here.
- Exclude checks
TODO found Open
// TODO: examine why this is so
- Exclude checks
TODO found Open
* TODO: release feature
- Exclude checks
TODO found Open
// TODO: perhaps move to HierarchicalStatus.
- Exclude checks