lib/network/modules/NodesHandler.js

Summary

Maintainability
F
3 days
Test Coverage

Function constructor has 122 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(body, images, groups, layoutEngine) {
    this.body = body;
    this.images = images;
    this.groups = groups;
    this.layoutEngine = layoutEngine;
Severity: Major
Found in lib/network/modules/NodesHandler.js - About 4 hrs to fix

    File NodesHandler.js has 368 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    let util = require("../../util");
    let DataSet = require('../../DataSet');
    let DataView = require('../../DataView');
    var Node = require("./components/Node").default;
    
    
    Severity: Minor
    Found in lib/network/modules/NodesHandler.js - About 4 hrs to fix

      Function setOptions has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

        setOptions(options) {
          if (options !== undefined) {
            Node.parseOptions(this.options, options);
      
            // update the shape in all nodes
      Severity: Minor
      Found in lib/network/modules/NodesHandler.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 getPositions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        getPositions(ids) {
          let dataArray = {};
          if (ids !== undefined) {
            if (Array.isArray(ids) === true) {
              for (let i = 0; i < ids.length; i++) {
      Severity: Minor
      Found in lib/network/modules/NodesHandler.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 getConnectedNodes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        getConnectedNodes(nodeId, direction) {
          let nodeList = [];
          if (this.body.nodes[nodeId] !== undefined) {
            let node = this.body.nodes[nodeId];
            let nodeObj = {}; // used to quickly check if node already exists
      Severity: Minor
      Found in lib/network/modules/NodesHandler.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        update(ids, changedData, oldData) {
          let nodes = this.body.nodes;
          let dataChanged = false;
          for (let i = 0; i < ids.length; i++) {
            let id = ids[i];
      Severity: Minor
      Found in lib/network/modules/NodesHandler.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 setData has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        setData(nodes, doNotEmit = false) {
          let oldNodesData = this.body.data.nodes;
      
          if (nodes instanceof DataSet || nodes instanceof DataView) {
            this.body.data.nodes = nodes;
      Severity: Minor
      Found in lib/network/modules/NodesHandler.js - About 1 hr to fix

        Function update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          update(ids, changedData, oldData) {
            let nodes = this.body.nodes;
            let dataChanged = false;
            for (let i = 0; i < ids.length; i++) {
              let id = ids[i];
        Severity: Minor
        Found in lib/network/modules/NodesHandler.js - About 1 hr to fix

          Function setOptions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            setOptions(options) {
              if (options !== undefined) {
                Node.parseOptions(this.options, options);
          
                // update the shape in all nodes
          Severity: Minor
          Found in lib/network/modules/NodesHandler.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (nodeObj[edge.toId] === undefined) {
                        nodeList.push(edge.toId);
                        nodeObj[edge.toId] = true;
                      }
            Severity: Major
            Found in lib/network/modules/NodesHandler.js - About 45 mins to fix

              Function setData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                setData(nodes, doNotEmit = false) {
                  let oldNodesData = this.body.data.nodes;
              
                  if (nodes instanceof DataSet || nodes instanceof DataView) {
                    this.body.data.nodes = nodes;
              Severity: Minor
              Found in lib/network/modules/NodesHandler.js - About 45 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 storePositions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                storePositions() {
                  // todo: add support for clusters and hierarchical.
                  let dataArray = [];
                  var dataset = this.body.data.nodes.getDataSet();
              
              
              Severity: Minor
              Found in lib/network/modules/NodesHandler.js - About 35 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

              There are no issues that match your filters.

              Category
              Status