lib/network/modules/components/physics/BarnesHutSolver.js

Summary

Maintainability
D
1 day
Test Coverage

File BarnesHutSolver.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Barnes Hut Solver
 */
class BarnesHutSolver {
  /**
Severity: Minor
Found in lib/network/modules/components/physics/BarnesHutSolver.js - About 3 hrs to fix

    Function _formBarnesHutTree has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      _formBarnesHutTree(nodes, nodeIndices) {
        let node;
        let nodeCount = nodeIndices.length;
    
        let minX = nodes[nodeIndices[0]].x;
    Severity: Minor
    Found in lib/network/modules/components/physics/BarnesHutSolver.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 _formBarnesHutTree has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _formBarnesHutTree(nodes, nodeIndices) {
        let node;
        let nodeCount = nodeIndices.length;
    
        let minX = nodes[nodeIndices[0]].x;
    Severity: Major
    Found in lib/network/modules/components/physics/BarnesHutSolver.js - About 2 hrs to fix

      Function _insertRegion has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _insertRegion(parentBranch, region) {
          let minX, maxX, minY, maxY;
          let childSize = 0.5 * parentBranch.size;
          switch (region) {
            case "NW":
      Severity: Minor
      Found in lib/network/modules/components/physics/BarnesHutSolver.js - About 1 hr to fix

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

          _getForceContribution(parentBranch, node) {
            // we get no force contribution from an empty region
            if (parentBranch.childrenCount > 0) {
              let dx, dy, distance;
        
        
        Severity: Minor
        Found in lib/network/modules/components/physics/BarnesHutSolver.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 _placeInTree has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          _placeInTree(parentBranch, node, skipMassUpdate) {
            if (skipMassUpdate != true || skipMassUpdate === undefined) {
              // update the mass of the branch.
              this._updateBranchMass(parentBranch, node);
            }
        Severity: Minor
        Found in lib/network/modules/components/physics/BarnesHutSolver.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 _drawBranch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _drawBranch(branch, ctx, color) {
            if (color === undefined) {
              color = "#FF0000";
            }
        
        
        Severity: Minor
        Found in lib/network/modules/components/physics/BarnesHutSolver.js - About 1 hr to fix

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

            solve() {
              if (this.options.gravitationalConstant !== 0 && this.physicsBody.physicsNodeIndices.length > 0) {
                let node;
                let nodes = this.body.nodes;
                let nodeIndices = this.physicsBody.physicsNodeIndices;
          Severity: Minor
          Found in lib/network/modules/components/physics/BarnesHutSolver.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 _drawBranch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _drawBranch(branch, ctx, color) {
              if (color === undefined) {
                color = "#FF0000";
              }
          
          
          Severity: Minor
          Found in lib/network/modules/components/physics/BarnesHutSolver.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