lib/network/modules/ManipulationSystem.js

Summary

Maintainability
F
6 days
Test Coverage

File ManipulationSystem.js has 783 lines of code (exceeds 250 allowed). Consider refactoring.
Open


let util = require('../../util');
let Hammer = require('../../module/hammer');
let hammerUtil = require('../../hammerUtil');

Severity: Major
Found in lib/network/modules/ManipulationSystem.js - About 1 day to fix

    ManipulationSystem has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ManipulationSystem {
      /**
       * @param {Object} body
       * @param {Canvas} canvas
       * @param {SelectionHandler} selectionHandler
    Severity: Minor
    Found in lib/network/modules/ManipulationSystem.js - About 6 hrs to fix

      Function showManipulatorToolbar has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

        showManipulatorToolbar() {
          // restore the state of any bound functions or events, remove control nodes, restore physics
          this._clean();
      
          // reset global variables
      Severity: Minor
      Found in lib/network/modules/ManipulationSystem.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 showManipulatorToolbar has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        showManipulatorToolbar() {
          // restore the state of any bound functions or events, remove control nodes, restore physics
          this._clean();
      
          // reset global variables
      Severity: Major
      Found in lib/network/modules/ManipulationSystem.js - About 2 hrs to fix

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

          deleteSelected() {
            // when using the gui, enable edit mode if it wasnt already.
            if (this.editMode !== true) {
              this.enableEditMode();
            }
        Severity: Minor
        Found in lib/network/modules/ManipulationSystem.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 editEdgeMode has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          editEdgeMode() {
            // when using the gui, enable edit mode if it wasn't already.
            if (this.editMode !== true) {
              this.enableEditMode();
            }
        Severity: Major
        Found in lib/network/modules/ManipulationSystem.js - About 2 hrs to fix

          Function deleteSelected has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            deleteSelected() {
              // when using the gui, enable edit mode if it wasnt already.
              if (this.editMode !== true) {
                this.enableEditMode();
              }
          Severity: Minor
          Found in lib/network/modules/ManipulationSystem.js - About 2 hrs to fix

            Function editNode has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              editNode() {
                // when using the gui, enable edit mode if it wasnt already.
                if (this.editMode !== true) {
                  this.enableEditMode();
                }
            Severity: Minor
            Found in lib/network/modules/ManipulationSystem.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 _controlNodeDragEnd has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              _controlNodeDragEnd(event) {
                let pointer = this.body.functions.getPointer(event.center);
                let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
                let edge = this.body.edges[this.edgeBeingEditedId];
                // if the node that was dragged is not a control node, return
            Severity: Minor
            Found in lib/network/modules/ManipulationSystem.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 13 (exceeds 5 allowed). Consider refactoring.
            Open

              setOptions(options, allOptions, globalOptions) {
                if (allOptions !== undefined) {
                  if (allOptions.locale !== undefined)  {this.options.locale = allOptions.locale}   else {this.options.locale = globalOptions.locale;}
                  if (allOptions.locales !== undefined) {this.options.locales = allOptions.locales} else {this.options.locales = globalOptions.locales;}
                }
            Severity: Minor
            Found in lib/network/modules/ManipulationSystem.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 _finishConnect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              _finishConnect(event) {
                let pointer = this.body.functions.getPointer(event.center);
                let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
            
                // remember the edge id
            Severity: Minor
            Found in lib/network/modules/ManipulationSystem.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 constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor(body, canvas, selectionHandler) {
                this.body = body;
                this.canvas = canvas;
                this.selectionHandler = selectionHandler;
            
            
            Severity: Minor
            Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

              Function editNode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                editNode() {
                  // when using the gui, enable edit mode if it wasnt already.
                  if (this.editMode !== true) {
                    this.enableEditMode();
                  }
              Severity: Minor
              Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

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

                  _controlNodeDragEnd(event) {
                    let pointer = this.body.functions.getPointer(event.center);
                    let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
                    let edge = this.body.edges[this.edgeBeingEditedId];
                    // if the node that was dragged is not a control node, return
                Severity: Minor
                Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

                  Function _handleConnect has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _handleConnect(event) {
                      // check to avoid double fireing of this function.
                      if (new Date().valueOf() - this.touchTime > 100) {
                        this.lastTouch = this.body.functions.getPointer(event.center);
                        this.lastTouch.translation = util.extend({},this.body.view.translation); // copy the object
                  Severity: Minor
                  Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

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

                      _performEditEdge(sourceNodeId, targetNodeId) {
                        let defaultData = {id: this.edgeBeingEditedId, from: sourceNodeId, to: targetNodeId, label: this.body.data.edges._data[this.edgeBeingEditedId].label };
                        let eeFunct = this.options.editEdge;
                        if (typeof eeFunct === 'object') {
                          eeFunct = eeFunct.editWithoutDrag;
                    Severity: Minor
                    Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

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

                        _createWrappers() {
                          // load the manipulator HTML elements. All styling done in css.
                          if (this.manipulationDiv === undefined) {
                            this.manipulationDiv = document.createElement('div');
                            this.manipulationDiv.className = 'vis-manipulation';
                      Severity: Minor
                      Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

                        Function _finishConnect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          _finishConnect(event) {
                            let pointer = this.body.functions.getPointer(event.center);
                            let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
                        
                            // remember the edge id
                        Severity: Minor
                        Found in lib/network/modules/ManipulationSystem.js - About 1 hr to fix

                          Function _createWrappers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            _createWrappers() {
                              // load the manipulator HTML elements. All styling done in css.
                              if (this.manipulationDiv === undefined) {
                                this.manipulationDiv = document.createElement('div');
                                this.manipulationDiv.className = 'vis-manipulation';
                          Severity: Minor
                          Found in lib/network/modules/ManipulationSystem.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

                          Function editEdgeMode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            editEdgeMode() {
                              // when using the gui, enable edit mode if it wasn't already.
                              if (this.editMode !== true) {
                                this.enableEditMode();
                              }
                          Severity: Minor
                          Found in lib/network/modules/ManipulationSystem.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

                                    if (needSeperator === true) {
                                      this._createSeperator(4);
                                    }
                          Severity: Major
                          Found in lib/network/modules/ManipulationSystem.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'editNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) {
                                            this.body.data.nodes.getDataSet().update(finalizedData);
                                          }
                            Severity: Major
                            Found in lib/network/modules/ManipulationSystem.js - About 45 mins to fix

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

                                _handleConnect(event) {
                                  // check to avoid double fireing of this function.
                                  if (new Date().valueOf() - this.touchTime > 100) {
                                    this.lastTouch = this.body.functions.getPointer(event.center);
                                    this.lastTouch.translation = util.extend({},this.body.view.translation); // copy the object
                              Severity: Minor
                              Found in lib/network/modules/ManipulationSystem.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 _performEditEdge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                _performEditEdge(sourceNodeId, targetNodeId) {
                                  let defaultData = {id: this.edgeBeingEditedId, from: sourceNodeId, to: targetNodeId, label: this.body.data.edges._data[this.edgeBeingEditedId].label };
                                  let eeFunct = this.options.editEdge;
                                  if (typeof eeFunct === 'object') {
                                    eeFunct = eeFunct.editWithoutDrag;
                              Severity: Minor
                              Found in lib/network/modules/ManipulationSystem.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 _cleanupTemporaryNodesAndEdges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                _cleanupTemporaryNodesAndEdges() {
                                  // _clean temporary edges
                                  for (let i = 0; i < this.temporaryIds.edges.length; i++) {
                                    this.body.edges[this.temporaryIds.edges[i]].disconnect();
                                    delete this.body.edges[this.temporaryIds.edges[i]];
                              Severity: Minor
                              Found in lib/network/modules/ManipulationSystem.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