lib/network/modules/SelectionHandler.js

Summary

Maintainability
F
3 days
Test Coverage

File SelectionHandler.js has 487 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Node = require('./components/Node').default;
var Edge = require('./components/Edge').default;

let util = require('../../util');

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

    SelectionHandler has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

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

      Function hoverObject has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        hoverObject(event, pointer) {
          let object = this.getNodeAt(pointer);
          if (object === undefined) {
            object = this.getEdgeAt(pointer);
          }
      Severity: Minor
      Found in lib/network/modules/SelectionHandler.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 setSelection has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        setSelection(selection, options = {}) {
          let i, id;
      
          if (!selection || (!selection.nodes && !selection.edges))
            throw 'Selection must be an object with nodes and/or edges properties';
      Severity: Minor
      Found in lib/network/modules/SelectionHandler.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 hoverObject has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        hoverObject(event, pointer) {
          let object = this.getNodeAt(pointer);
          if (object === undefined) {
            object = this.getEdgeAt(pointer);
          }
      Severity: Minor
      Found in lib/network/modules/SelectionHandler.js - About 1 hr to fix

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

          updateSelection() {
            for (let nodeId in this.selectionObj.nodes) {
              if (this.selectionObj.nodes.hasOwnProperty(nodeId)) {
                if (!this.body.nodes.hasOwnProperty(nodeId)) {
                  delete this.selectionObj.nodes[nodeId];
        Severity: Minor
        Found in lib/network/modules/SelectionHandler.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 getEdgeAt has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          getEdgeAt(pointer, returnEdge = true) {
            // Iterate over edges, pick closest within 10
            var canvasPos = this.canvas.DOMtoCanvas(pointer);
            var mindist = 10;
            var overlappingEdge = null;
        Severity: Minor
        Found in lib/network/modules/SelectionHandler.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 getEdgeAt has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getEdgeAt(pointer, returnEdge = true) {
            // Iterate over edges, pick closest within 10
            var canvasPos = this.canvas.DOMtoCanvas(pointer);
            var mindist = 10;
            var overlappingEdge = null;
        Severity: Minor
        Found in lib/network/modules/SelectionHandler.js - About 1 hr to fix

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

            setSelection(selection, options = {}) {
              let i, id;
          
              if (!selection || (!selection.nodes && !selection.edges))
                throw 'Selection must be an object with nodes and/or edges properties';
          Severity: Minor
          Found in lib/network/modules/SelectionHandler.js - About 1 hr to fix

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

              selectAdditionalOnPoint(pointer) {
                let selectionChanged = false;
                if (this.options.selectable === true) {
                  let obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);
            
            
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 _clusterInSelection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              _clusterInSelection() {
                for(let nodeId in this.selectionObj.nodes) {
                  if(this.selectionObj.nodes.hasOwnProperty(nodeId)) {
                    if (this.selectionObj.nodes[nodeId].clusterSize > 1) {
                      return true;
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 _getSelectedObjectCount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              _getSelectedObjectCount() {
                let count = 0;
                for(let nodeId in this.selectionObj.nodes) {
                  if(this.selectionObj.nodes.hasOwnProperty(nodeId)) {
                    count += 1;
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 getSelectedEdges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              getSelectedEdges() {
                let idArray = [];
                if (this.options.selectable === true) {
                  for (let edgeId in this.selectionObj.edges) {
                    if (this.selectionObj.edges.hasOwnProperty(edgeId)) {
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 unselectAll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              unselectAll() {
                for(let nodeId in this.selectionObj.nodes) {
                  if(this.selectionObj.nodes.hasOwnProperty(nodeId)) {
                    this.selectionObj.nodes[nodeId].unselect();
                  }
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 _selectionIsEmpty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              _selectionIsEmpty() {
                for(let nodeId in this.selectionObj.nodes) {
                  if(this.selectionObj.nodes.hasOwnProperty(nodeId)) {
                    return false;
                  }
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 getSelectedNodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              getSelectedNodes() {
                let idArray = [];
                if (this.options.selectable === true) {
                  for (let nodeId in this.selectionObj.nodes) {
                    if (this.selectionObj.nodes.hasOwnProperty(nodeId)) {
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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 selectObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              selectObject(obj, highlightEdges = this.options.selectConnectedEdges) {
                if (obj !== undefined) {
                  if (obj instanceof Node) {
                    if (highlightEdges === true) {
                      this._selectConnectedEdges(obj);
            Severity: Minor
            Found in lib/network/modules/SelectionHandler.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