Function clusterByEdgeCount
has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring. Open
clusterByEdgeCount(edgeCount, options, refreshData = true) {
options = this._checkOptions(options);
let clusters = [];
let usedNodes = {};
let edge, edges, relevantEdgeCount;
- 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 Clustering.js
has 790 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* ===========================================================================
# TODO
- `edgeReplacedById` not cleaned up yet on cluster edge removal
Function openCluster
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
openCluster(clusterNodeId, options, refreshData = true) {
// kill conditions
if (clusterNodeId === undefined) {
throw new Error("No clusterNodeId supplied to openCluster.");
}
- 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 clusterByConnection
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
clusterByConnection(nodeId, options, refreshData = true) {
// kill conditions
if (nodeId === undefined) {throw new Error("No nodeId supplied to clusterByConnection!");}
if (this.body.nodes[nodeId] === undefined) {throw new Error("The nodeId given to clusterByConnection does not exist!");}
- 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 _cluster
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
_cluster(childNodesObj, childEdgesObj, options, refreshData = true) {
// Remove nodes which are already clustered
var tmpNodesToRemove = []
for (let nodeId in childNodesObj) {
if (childNodesObj.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 _updateState
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
_updateState() {
let nodeId;
let deletedNodeIds = [];
let deletedEdgeIds = [];
Function _createClusterEdges
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
_createClusterEdges (childNodesObj, childEdgesObj, clusterNodeProperties, clusterEdgeProperties) {
let edge, childNodeId, childNode, toId, fromId, otherNodeId;
// loop over all child nodes and their edges to find edges going out of the cluster
// these edges will be replaced by clusterEdges.
- 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 openCluster
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
openCluster(clusterNodeId, options, refreshData = true) {
// kill conditions
if (clusterNodeId === undefined) {
throw new Error("No clusterNodeId supplied to openCluster.");
}
ClusterEngine
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class ClusterEngine {
/**
* @param {Object} body
*/
constructor(body) {
Function clusterByEdgeCount
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
clusterByEdgeCount(edgeCount, options, refreshData = true) {
options = this._checkOptions(options);
let clusters = [];
let usedNodes = {};
let edge, edges, relevantEdgeCount;
Function _cluster
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
_cluster(childNodesObj, childEdgesObj, options, refreshData = true) {
// Remove nodes which are already clustered
var tmpNodesToRemove = []
for (let nodeId in childNodesObj) {
if (childNodesObj.hasOwnProperty(nodeId)) {
Function _createClusterEdges
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createClusterEdges (childNodesObj, childEdgesObj, clusterNodeProperties, clusterEdgeProperties) {
let edge, childNodeId, childNode, toId, fromId, otherNodeId;
// loop over all child nodes and their edges to find edges going out of the cluster
// these edges will be replaced by clusterEdges.
Function clusterByConnection
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
clusterByConnection(nodeId, options, refreshData = true) {
// kill conditions
if (nodeId === undefined) {throw new Error("No nodeId supplied to clusterByConnection!");}
if (this.body.nodes[nodeId] === undefined) {throw new Error("The nodeId given to clusterByConnection does not exist!");}
Function getBaseEdges
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
getBaseEdges(clusteredEdgeId) {
let IdsToHandle = [clusteredEdgeId];
let doneIds = [];
let foundIds = [];
let max = 100;
- 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 _updateState
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
_updateState() {
let nodeId;
let deletedNodeIds = [];
let deletedEdgeIds = [];
- 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 _clusterEdges
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
_clusterEdges(childNodes, childEdges, clusterNode, clusterEdgeProperties) {
if (childEdges instanceof Edge) {
let edge = childEdges;
let obj = {};
obj[edge.id] = 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 _clusterEdges
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_clusterEdges(childNodes, childEdges, clusterNode, clusterEdgeProperties) {
if (childEdges instanceof Edge) {
let edge = childEdges;
let obj = {};
obj[edge.id] = edge;
Function getBaseEdges
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
getBaseEdges(clusteredEdgeId) {
let IdsToHandle = [clusteredEdgeId];
let doneIds = [];
let foundIds = [];
let max = 100;
Function _getClusterPosition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_getClusterPosition(childNodesObj) {
let childKeys = Object.keys(childNodesObj);
let minX = childNodesObj[childKeys[0]].x;
let maxX = childNodesObj[childKeys[0]].x;
let minY = childNodesObj[childKeys[0]].y;
- 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
for (let n = 0; n < clusters.length; ++n) {
// Search for a cluster containing any of the node id's
for (var m in childNodesObj) {
if (clusters[n].nodes[m] !== undefined) {
return clusters[n];
Avoid deeply nested control flow statements. Open
if (foundCluster !== undefined) {
// Add nodes to found cluster if not present
for (let m in childNodesObj) {
if (foundCluster.nodes[m] === undefined) {
foundCluster.nodes[m] = childNodesObj[m];
Avoid deeply nested control flow statements. Open
if (checkJoinCondition(node)) {
childEdgesObj[edge.id] = edge;
childNodesObj[nodeId] = node;
childNodesObj[childNodeId] = this.body.nodes[childNodeId];
usedNodes[nodeId] = true;
Avoid deeply nested control flow statements. Open
if (edge.toId == childNodeId) { // this is a double equals because ints and strings can be interchanged here.
toId = clusterNodeProperties.id;
fromId = edge.fromId;
otherNodeId = fromId;
}
Avoid deeply nested control flow statements. Open
if (options.joinCondition === undefined) {
childEdgesObj[edge.id] = edge;
childNodesObj[childNodeId] = this.body.nodes[childNodeId];
}
else {
Avoid deeply nested control flow statements. Open
if (edge.toId !== edge.fromId) {
relevantEdgeCount++;
}
Function getNodesInCluster
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getNodesInCluster(clusterId) {
let nodesArray = [];
if (this.isCluster(clusterId) === true) {
let containedNodes = this.body.nodes[clusterId].containedNodes;
for (let nodeId in containedNodes) {
- 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 clusterByHubsize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
clusterByHubsize(hubsize, options) {
if (hubsize === undefined) {
hubsize = this._getHubSize();
}
else if (typeof(hubsize) === "object") {
- 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
# TODO
- Exclude checks
TODO found Open
// TODO: check that it works for both edges clustered
- Exclude checks
TODO found Open
// TODO: never triggers; find a test-case which does
- Exclude checks
TODO found Open
* TODO: deprecate in 5.0.0. Method getBaseEdges() is the correct one to use.
- Exclude checks