packages/miew/src/gfx/geometries/ContactSurface.js

Summary

Maintainability
F
1 wk
Test Coverage

Function ContactSurface has a Cognitive Complexity of 122 (exceeds 5 allowed). Consider refactoring.
Open

function ContactSurface(packedArrays, boundaries, params, _indexList) {
  // Field generation method adapted from AstexViewer (Mike Hartshorn)
  // by Fred Ludlow.
  // Other parts based heavily on NGL (Alexander Rose) EDT Surface class
  //
Severity: Minor
Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 2 days 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 ContactSurface has 324 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ContactSurface(packedArrays, boundaries, params, _indexList) {
  // Field generation method adapted from AstexViewer (Mike Hartshorn)
  // by Fred Ludlow.
  // Other parts based heavily on NGL (Alexander Rose) EDT Surface class
  //
Severity: Major
Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 1 day to fix

    File ContactSurface.js has 421 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import utils from '../../utils'
    import { Vector3 } from 'three'
    
    /**
     * Modifed from SpatialHash
    Severity: Minor
    Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 6 hrs to fix

      Function AVHash has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      function AVHash(posRad, min, max, maxDistance) {
        const itemSize = 4
        const nAtoms = posRad.length / itemSize
      
        const minX = min[0]
      Severity: Minor
      Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 4 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 AVHash has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function AVHash(posRad, min, max, maxDistance) {
        const itemSize = 4
        const nAtoms = posRad.length / itemSize
      
        const minX = min[0]
      Severity: Major
      Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 3 hrs to fix

        Function projectPoints has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function projectPoints() {
            // For each atom:
            //     Iterate over a subsection of the grid, for each point:
            //         If current value < 0.0, unvisited, set positive
            //
        Severity: Major
        Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 2 hrs to fix

          Function projectTorus has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function projectTorus(a, b) {
              const aIdx = itemSize * a
              const bIdx = itemSize * b
              const xa = posRad[aIdx]
              const ya = posRad[aIdx + 1]
          Severity: Major
          Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 2 hrs to fix

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

              this.withinRadii = function (x, y, z, rExtra, out) {
                let outIdx = 0
            
                const nearI = hashFunc(x, minX)
                const nearJ = hashFunc(y, minY)
            Severity: Minor
            Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                          if (d2 < ar2) {
                            const w = Math.exp(-d2 * sigma2Inv)
                            const cIdx = idx * 3
                            volTex[cIdx] += cr * w
                            volTex[cIdx + 1] += cg * w
              Severity: Major
              Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (dx * dx + dy * dy + dz * dz <= rSum * rSum) {
                              out[outIdx++] = data[dataIndex]
                            }
                Severity: Major
                Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              for (let ix = minx; ix < maxx; ix++) {
                                dx = px - gridx[ix]
                                d2 = dzy2 + dx * dx
                                const idx = ix + zyOffset
                                const current = grid[idx]
                  Severity: Major
                  Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 45 mins to fix

                    Function obscured has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function obscured(innX, innY, innZ, a, b) {
                    Severity: Minor
                    Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 35 mins to fix

                      Function withinRadii has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        this.withinRadii = function (x, y, z, rExtra, out) {
                      Severity: Minor
                      Found in packages/miew/src/gfx/geometries/ContactSurface.js - About 35 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status