lib/network/modules/InteractionHandler.js

Summary

Maintainability
F
4 days
Test Coverage

File InteractionHandler.js has 434 lines of code (exceeds 250 allowed). Consider refactoring.
Open

let util = require('../../util');
var NavigationHandler = require('./components/NavigationHandler').default;
var Popup = require('./../../shared/Popup').default;


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

    Function _checkShowPopup has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

     _checkShowPopup(pointer) {
        let x = this.canvas._XconvertDOMtoCanvas(pointer.x);
        let y = this.canvas._YconvertDOMtoCanvas(pointer.y);
        let pointerObj = {
          left:   x,
    Severity: Minor
    Found in lib/network/modules/InteractionHandler.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 _checkShowPopup has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

     _checkShowPopup(pointer) {
        let x = this.canvas._XconvertDOMtoCanvas(pointer.x);
        let y = this.canvas._YconvertDOMtoCanvas(pointer.y);
        let pointerObj = {
          left:   x,
    Severity: Major
    Found in lib/network/modules/InteractionHandler.js - About 2 hrs to fix

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

       _checkHidePopup(pointer) {
          let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
      
          let stillOnObj = false;
          if (this.popup.popupTargetType === 'node') {
      Severity: Minor
      Found in lib/network/modules/InteractionHandler.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

      InteractionHandler has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

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

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

          zoom(scale, pointer) {
            if (this.options.zoomView === true) {
              let scaleOld = this.body.view.scale;
              if (scale < 0.00001) {
                scale = 0.00001;
        Severity: Minor
        Found in lib/network/modules/InteractionHandler.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 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

            onDragStart(event) {
              //in case the touch event was triggered on an external div, do the initial touch now.
              if (this.drag.pointer === undefined) {
                this.onTouch(event);
              }
          Severity: Minor
          Found in lib/network/modules/InteractionHandler.js - About 1 hr to fix

            Function onMouseMove has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              onMouseMove(event) {
                let pointer = this.getPointer({x:event.clientX, y:event.clientY});
                let popupVisible = false;
            
                // check if the previously selected node is still selected
            Severity: Minor
            Found in lib/network/modules/InteractionHandler.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 onDrag has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              onDrag(event) {
                if (this.drag.pinched === true) {
                  return;
                }
            
            
            Severity: Minor
            Found in lib/network/modules/InteractionHandler.js - About 1 hr to fix

              Function zoom has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                zoom(scale, pointer) {
                  if (this.options.zoomView === true) {
                    let scaleOld = this.body.view.scale;
                    if (scale < 0.00001) {
                      scale = 0.00001;
              Severity: Minor
              Found in lib/network/modules/InteractionHandler.js - About 1 hr to fix

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

                  onDragStart(event) {
                    //in case the touch event was triggered on an external div, do the initial touch now.
                    if (this.drag.pointer === undefined) {
                      this.onTouch(event);
                    }
                Severity: Minor
                Found in lib/network/modules/InteractionHandler.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 checkSelectionChanges has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  checkSelectionChanges(pointer, event, add = false) {
                    let previousSelection = this.selectionHandler.getSelection();
                    let selected = false;
                    if (add === true) {
                      selected = this.selectionHandler.selectAdditionalOnPoint(pointer);
                Severity: Minor
                Found in lib/network/modules/InteractionHandler.js - About 1 hr to fix

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

                    onMouseMove(event) {
                      let pointer = this.getPointer({x:event.clientX, y:event.clientY});
                      let popupVisible = false;
                  
                      // check if the previously selected node is still selected
                  Severity: Minor
                  Found in lib/network/modules/InteractionHandler.js - About 1 hr to fix

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

                      onMouseWheel(event) {
                        if (this.options.zoomView === true) {
                          // retrieve delta
                          let delta = 0;
                          if (event.wheelDelta) { /* IE/Opera. */
                    Severity: Minor
                    Found in lib/network/modules/InteractionHandler.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 onDrag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      onDrag(event) {
                        if (this.drag.pinched === true) {
                          return;
                        }
                    
                    
                    Severity: Minor
                    Found in lib/network/modules/InteractionHandler.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 checkSelectionChanges has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      checkSelectionChanges(pointer, event, add = false) {
                        let previousSelection = this.selectionHandler.getSelection();
                        let selected = false;
                        if (add === true) {
                          selected = this.selectionHandler.selectAdditionalOnPoint(pointer);
                    Severity: Minor
                    Found in lib/network/modules/InteractionHandler.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 setOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      setOptions(options) {
                        if (options !== undefined) {
                          // extend all but the values in fields
                          let fields = ['hideEdgesOnDrag','hideNodesOnDrag','keyboard','multiselect','selectable','selectConnectedEdges'];
                          util.selectiveNotDeepExtend(fields, this.options, options);
                    Severity: Minor
                    Found in lib/network/modules/InteractionHandler.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: enabled moving while pinching?

                    TODO found
                    Open

                       * TODO: This is all SelectionHandler calls; the method should be moved to there.

                    There are no issues that match your filters.

                    Category
                    Status