lib/network/modules/components/Node.js

Summary

Maintainability
D
2 days
Test Coverage

File Node.js has 366 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 Box = require('./nodes/shapes/Box').default;
Severity: Minor
Found in lib/network/modules/components/Node.js - About 4 hrs to fix

    Node has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Node {
      /**
       *
       * @param {object} options An object containing options for the node. All
       *                            options are optional, except for the id.
    Severity: Minor
    Found in lib/network/modules/components/Node.js - About 3 hrs to fix

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

        getFormattingValues() {
          let values = {
            color: this.options.color.background,
            borderWidth: this.options.borderWidth,
            borderColor: this.options.color.border,
      Severity: Minor
      Found in lib/network/modules/components/Node.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 updateShape has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        updateShape(currentShape) {
          if (currentShape === this.options.shape && this.shape) {
            this.shape.setOptions(this.options, this.imageObj, this.imageObjAlt);
          }
          else {
      Severity: Major
      Found in lib/network/modules/components/Node.js - About 2 hrs to fix

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

          static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}, groupList) {
        
            var fields = [
              'color',
              'fixed',
        Severity: Minor
        Found in lib/network/modules/components/Node.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 setOptions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          setOptions(options) {
            let currentShape = this.options.shape;
            if (!options) {
              return;  // Note that the return value will be 'undefined'! This is OK.
            }
        Severity: Minor
        Found in lib/network/modules/components/Node.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 getFormattingValues has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getFormattingValues() {
            let values = {
              color: this.options.color.background,
              borderWidth: this.options.borderWidth,
              borderColor: this.options.color.border,
        Severity: Minor
        Found in lib/network/modules/components/Node.js - About 1 hr to fix

          Function parseOptions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}, groupList) {
          
              var fields = [
                'color',
                'fixed',
          Severity: Minor
          Found in lib/network/modules/components/Node.js - About 1 hr to fix

            Function _load_images has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              _load_images() {
                // Don't bother loading for nodes without images
                if (this.options.shape !== 'circularImage' && this.options.shape !== 'image') {
                  return;
                }
            Severity: Minor
            Found in lib/network/modules/components/Node.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 setOptions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              setOptions(options) {
                let currentShape = this.options.shape;
                if (!options) {
                  return;  // Note that the return value will be 'undefined'! This is OK.
                }
            Severity: Minor
            Found in lib/network/modules/components/Node.js - About 1 hr to fix

              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/Node.js - About 45 mins to fix

                TODO found
                Open

                    // TODO: It might not be a good idea either to merge the rest of the options, investigate this. 

                TODO found
                Open

                   * TODO: The imageObj members should be moved to CircularImageBase.

                There are no issues that match your filters.

                Category
                Status