lib/network/modules/EdgesHandler.js

Summary

Maintainability
D
2 days
Test Coverage

File EdgesHandler.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require("../../util");
var DataSet = require('../../DataSet');
var DataView = require('../../DataView');
var Edge = require("./components/Edge").default;

Severity: Minor
Found in lib/network/modules/EdgesHandler.js - About 3 hrs to fix

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

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

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

        setOptions(options) {
          if (options !== undefined) {
            // use the parser from the Edge class to fill in all shorthand notations
            Edge.parseOptions(this.options, options, true, this.defaultOptions, true);
      
      
      Severity: Minor
      Found in lib/network/modules/EdgesHandler.js - About 3 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 bindEventListeners has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        bindEventListeners() {
          // this allows external modules to force all dynamic curves to turn static.
          this.body.emitter.on("_forceDisableDynamicCurves", (type, emit = true) => {
            if (type === 'dynamic') {
              type = 'continuous';
      Severity: Minor
      Found in lib/network/modules/EdgesHandler.js - About 1 hr to fix

        Function setData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Avoid deeply nested control flow statements.
          Open

                        if (smoothOptions.enabled === true && smoothOptions.type === 'dynamic') {
                          if (type === undefined) {
                            edge.setOptions({smooth: false});
                          }
                          else {
          Severity: Major
          Found in lib/network/modules/EdgesHandler.js - About 45 mins to fix

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

              setData(edges, doNotEmit = false) {
                var oldEdgesData = this.body.data.edges;
            
                if (edges instanceof DataSet || edges instanceof DataView) {
                  this.body.data.edges = edges;
            Severity: Minor
            Found in lib/network/modules/EdgesHandler.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

            Function reconnectEdges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              reconnectEdges() {
                var id;
                var nodes = this.body.nodes;
                var edges = this.body.edges;
            
            
            Severity: Minor
            Found in lib/network/modules/EdgesHandler.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              update(ids) {
                var edges = this.body.edges;
                var edgesData = this.body.data.edges;
                var dataChanged = false;
                for (var i = 0; i < ids.length; i++) {
            Severity: Minor
            Found in lib/network/modules/EdgesHandler.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: Verify and examine the consequences of this. It might still trigger when
            Severity: Minor
            Found in lib/network/modules/EdgesHandler.js by fixme

            TODO found
            Open

                // TODO: is this null or undefined or false?
            Severity: Minor
            Found in lib/network/modules/EdgesHandler.js by fixme

            TODO found
            Open

                // TODO: is this null or undefined or false?
            Severity: Minor
            Found in lib/network/modules/EdgesHandler.js by fixme

            There are no issues that match your filters.

            Category
            Status