lib/network/modules/Clustering.js

Summary

Maintainability
F
1 wk
Test Coverage

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;
Severity: Minor
Found in lib/network/modules/Clustering.js - About 1 day to fix

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
Severity: Major
Found in lib/network/modules/Clustering.js - About 1 day to fix

    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.");
        }
    Severity: Minor
    Found in lib/network/modules/Clustering.js - About 1 day to fix

    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!");}
    
    
    Severity: Minor
    Found in lib/network/modules/Clustering.js - About 5 hrs to fix

    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)) {
    Severity: Minor
    Found in lib/network/modules/Clustering.js - About 5 hrs to fix

    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 = [];
    
    
    Severity: Major
    Found in lib/network/modules/Clustering.js - About 4 hrs to fix

      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.
      Severity: Minor
      Found in lib/network/modules/Clustering.js - About 4 hrs to fix

      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.");
          }
      Severity: Major
      Found in lib/network/modules/Clustering.js - About 4 hrs to fix

        ClusterEngine has 31 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ClusterEngine {
          /**
           * @param {Object} body
           */
          constructor(body) {
        Severity: Minor
        Found in lib/network/modules/Clustering.js - About 3 hrs to fix

          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;
          Severity: Major
          Found in lib/network/modules/Clustering.js - About 3 hrs to fix

            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)) {
            Severity: Major
            Found in lib/network/modules/Clustering.js - About 2 hrs to fix

              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.
              Severity: Major
              Found in lib/network/modules/Clustering.js - About 2 hrs to fix

                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!");}
                
                
                Severity: Major
                Found in lib/network/modules/Clustering.js - About 2 hrs to fix

                  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;
                  Severity: Minor
                  Found in lib/network/modules/Clustering.js - About 2 hrs to fix

                  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 = [];
                  
                  
                  Severity: Minor
                  Found in lib/network/modules/Clustering.js - About 1 hr to fix

                  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;
                  Severity: Minor
                  Found in lib/network/modules/Clustering.js - About 1 hr to fix

                  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;
                  Severity: Minor
                  Found in lib/network/modules/Clustering.js - About 1 hr to fix

                    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;
                    Severity: Minor
                    Found in lib/network/modules/Clustering.js - About 1 hr to fix

                      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;
                      Severity: Minor
                      Found in lib/network/modules/Clustering.js - About 55 mins to fix

                      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];
                      Severity: Major
                      Found in lib/network/modules/Clustering.js - About 45 mins to fix

                        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];
                        Severity: Major
                        Found in lib/network/modules/Clustering.js - About 45 mins to fix

                          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;
                          Severity: Major
                          Found in lib/network/modules/Clustering.js - About 45 mins to fix

                            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;
                                        }
                            Severity: Major
                            Found in lib/network/modules/Clustering.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (options.joinCondition === undefined) {
                                            childEdgesObj[edge.id] = edge;
                                            childNodesObj[childNodeId] = this.body.nodes[childNodeId];
                                          }
                                          else {
                              Severity: Major
                              Found in lib/network/modules/Clustering.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (edge.toId !== edge.fromId) {
                                              relevantEdgeCount++;
                                            }
                                Severity: Major
                                Found in lib/network/modules/Clustering.js - About 45 mins to fix

                                  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) {
                                  Severity: Minor
                                  Found in lib/network/modules/Clustering.js - About 25 mins to fix

                                  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") {
                                  Severity: Minor
                                  Found in lib/network/modules/Clustering.js - About 25 mins to fix

                                  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
                                  Severity: Minor
                                  Found in lib/network/modules/Clustering.js by fixme

                                  TODO found
                                  Open

                                                  // TODO: check that it works for both edges clustered
                                  Severity: Minor
                                  Found in lib/network/modules/Clustering.js by fixme

                                  TODO found
                                  Open

                                            // TODO: never triggers; find a test-case which does
                                  Severity: Minor
                                  Found in lib/network/modules/Clustering.js by fixme

                                  TODO found
                                  Open

                                    * TODO: deprecate in 5.0.0. Method getBaseEdges() is the correct one to use.
                                  Severity: Minor
                                  Found in lib/network/modules/Clustering.js by fixme

                                  There are no issues that match your filters.

                                  Category
                                  Status