lib/network/modules/components/Edge.js

Summary

Maintainability
F
5 days
Test Coverage

Function parseOptions has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}, copyFromGlobals = false) {
    var fields = [
      'arrowStrikethrough',
      'id',
      'from',
Severity: Minor
Found in lib/network/modules/components/Edge.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 Edge.js has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require('../../../util');
var Label = require('./shared/Label').default;
var ComponentUtil = require('./shared/ComponentUtil').default;
var CubicBezierEdge = require('./edges/CubicBezierEdge').default;
var BezierEdgeDynamic = require('./edges/BezierEdgeDynamic').default;
Severity: Major
Found in lib/network/modules/components/Edge.js - About 1 day to fix

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

      getFormattingValues() {
        let toArrow = (this.options.arrows.to === true) || (this.options.arrows.to.enabled === true)
        let fromArrow = (this.options.arrows.from === true) || (this.options.arrows.from.enabled === true)
        let middleArrow = (this.options.arrows.middle === true) || (this.options.arrows.middle.enabled === true)
        let inheritsColor = this.options.color.inherit;
    Severity: Minor
    Found in lib/network/modules/components/Edge.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 parseOptions has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}, copyFromGlobals = false) {
        var fields = [
          'arrowStrikethrough',
          'id',
          'from',
    Severity: Major
    Found in lib/network/modules/components/Edge.js - About 4 hrs to fix

      Function updateEdgeType has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        updateEdgeType() {
          let smooth = this.options.smooth;
          let dataChanged = false;
          let changeInType = true;
          if (this.edgeType !== undefined) {
      Severity: Minor
      Found in lib/network/modules/components/Edge.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

      Edge has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Edge {
        /**
         * @param {Object} options        values specific to this edge, must contain at least 'from' and 'to'
         * @param {Object} body           shared state from Network instance
         * @param {Object} globalOptions  options from the EdgesHandler instance
      Severity: Minor
      Found in lib/network/modules/components/Edge.js - About 2 hrs to fix

        Function getFormattingValues has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getFormattingValues() {
            let toArrow = (this.options.arrows.to === true) || (this.options.arrows.to.enabled === true)
            let fromArrow = (this.options.arrows.from === true) || (this.options.arrows.from.enabled === true)
            let middleArrow = (this.options.arrows.middle === true) || (this.options.arrows.middle.enabled === true)
            let inheritsColor = this.options.color.inherit;
        Severity: Major
        Found in lib/network/modules/components/Edge.js - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                if ((((this.edgeType instanceof BezierEdgeDynamic) &&
                      (smooth.enabled === true) &&
                      (smooth.type === 'dynamic'))) ||
                    (((this.edgeType instanceof CubicBezierEdge) &&
                      (smooth.enabled === true) &&
          Severity: Critical
          Found in lib/network/modules/components/Edge.js - About 2 hrs to fix

            Function drawLabel has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              drawLabel(ctx, viaNode) {
                if (this.options.label !== undefined) {
                  // set style
                  var node1 = this.from;
                  var node2 = this.to;
            Severity: Minor
            Found in lib/network/modules/components/Edge.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 updateEdgeType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              updateEdgeType() {
                let smooth = this.options.smooth;
                let dataChanged = false;
                let changeInType = true;
                if (this.edgeType !== undefined) {
            Severity: Minor
            Found in lib/network/modules/components/Edge.js - About 1 hr to fix

              Function drawLabel has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                drawLabel(ctx, viaNode) {
                  if (this.options.label !== undefined) {
                    // set style
                    var node1 = this.from;
                    var node2 = this.to;
              Severity: Minor
              Found in lib/network/modules/components/Edge.js - About 1 hr to fix

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

                  setOptions(options) {
                    if (!options) {
                      return;
                    }
                
                
                Severity: Minor
                Found in lib/network/modules/components/Edge.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (typeof hoverWidth === 'function') {
                              values.width = hoverWidth(values.width);
                            } else if (typeof hoverWidth === 'number') {
                              values.width += hoverWidth;
                            }
                  Severity: Major
                  Found in lib/network/modules/components/Edge.js - About 45 mins to fix

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

                      setOptions(options) {
                        if (!options) {
                          return;
                        }
                    
                    
                    Severity: Minor
                    Found in lib/network/modules/components/Edge.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 connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      connect() {
                        this.disconnect();
                    
                        this.from = this.body.nodes[this.fromId] || undefined;
                        this.to = this.body.nodes[this.toId] || undefined;
                    Severity: Minor
                    Found in lib/network/modules/components/Edge.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 draw has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      draw(ctx) {
                        let values = this.getFormattingValues();
                        if (values.hidden) {
                          return;
                        }
                    Severity: Minor
                    Found in lib/network/modules/components/Edge.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

                    Avoid deeply nested control flow statements.
                    Open

                              if ((values.shadowColor !== this.options.shadow.color) ||
                                  (values.shadowSize !== this.options.shadow.size) ||
                                  (values.shadowX !== this.options.shadow.x) ||
                                  (values.shadowY !== this.options.shadow.y)) {
                                values.shadow = true;
                    Severity: Major
                    Found in lib/network/modules/components/Edge.js - About 45 mins to fix

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

                        _getRotation(ctx) {
                          let viaNode = this.edgeType.getViaNode();
                          let point = this.edgeType.getPoint(0.5, viaNode);
                      
                          if (ctx !== undefined) {
                      Severity: Minor
                      Found in lib/network/modules/components/Edge.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

                      There are no issues that match your filters.

                      Category
                      Status