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

Summary

Maintainability
F
1 wk
Test Coverage

File SSIsosurfaceGeometry.js has 721 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import IsoSurfaceGeometry from './IsoSurfaceGeometry'
import IsoSurfaceAtomColored from './IsoSurfaceAtomColored'
import IsosurfaceBuildNormals from './IsosurfaceBuildNormals'
import IsoSurfaceMarchCube from './IsoSurfaceMarchCube'
import IsoSurfaceGeo from './IsoSurfaceGeo'
Severity: Major
Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 1 day to fix

    Function _innerBuild has 155 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _innerBuild() {
        let ok
        const expandFactor = 1.2
    
        // performance test
    Severity: Major
    Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 6 hrs to fix

      Function buildGeoFromCorners has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

        buildGeoFromCorners(meshRes, vBoxMin, vBoxMax, corners, vCellStep, cube) {
          const arrSize = 12
          const cNumVerts = 8
          const numCells = meshRes - 1
          const side = meshRes
      Severity: Minor
      Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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 modifyExcludedFromGeo has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

        modifyExcludedFromGeo(
          side,
          probeSphereRadius,
          vBoxMin,
          vBoxMax,
      Severity: Minor
      Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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 buildGeoFromCorners has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        buildGeoFromCorners(meshRes, vBoxMin, vBoxMax, corners, vCellStep, cube) {
          const arrSize = 12
          const cNumVerts = 8
          const numCells = meshRes - 1
          const side = meshRes
      Severity: Major
      Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 3 hrs to fix

        Function calculateGridCorners has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          calculateGridCorners(corners, side, vBoxMin, vBoxMax, atoms, probeRad) {
            const side2 = side * side
            const side3 = side2 * side
            const vCorner = new Vector3()
            const vDif = new Vector3()
        Severity: Minor
        Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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 getNumIntersectedCells has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          getNumIntersectedCells(side, numCells, corners, cube) {
            const side2 = side * side
            const cNumVerts = 8
            let numIntersectedCells = 0
        
        
        Severity: Minor
        Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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 modifyExcludedFromGeo has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          modifyExcludedFromGeo(
            side,
            probeSphereRadius,
            vBoxMin,
            vBoxMax,
        Severity: Major
        Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 2 hrs to fix

          Function addVertexToGeo has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            addVertexToGeo(geoOut, vAdd) {
              let entry
              const oneHynberes = 0.01
              const n815851 = 815851
              const n37633 = 37633
          Severity: Major
          Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 2 hrs to fix

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

              calculateGridCorners(corners, side, vBoxMin, vBoxMax, atoms, probeRad) {
                const side2 = side * side
                const side3 = side2 * side
                const vCorner = new Vector3()
                const vDif = new Vector3()
            Severity: Minor
            Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 2 hrs to fix

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

                getBoundingBox(atoms, vBoxMin, vBoxMax) {
                  const bigNum = 10000000.0
              
                  vBoxMin.x = vBoxMin.y = vBoxMin.z = bigNum
                  vBoxMax.x = vBoxMax.y = vBoxMax.z = 0 - bigNum
              Severity: Minor
              Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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 getNumIntersectedCells has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getNumIntersectedCells(side, numCells, corners, cube) {
                  const side2 = side * side
                  const cNumVerts = 8
                  let numIntersectedCells = 0
              
              
              Severity: Minor
              Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 1 hr to fix

                Function _fromGeo has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _fromGeo(geoOut) {
                    let colors = null
                    const positions = utils.allocateTyped(
                      Float32Array,
                      (1 + 2) * geoOut._numVertices
                Severity: Minor
                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 1 hr to fix

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

                    getBoundingBox(atoms, vBoxMin, vBoxMax) {
                      const bigNum = 10000000.0
                  
                      vBoxMin.x = vBoxMin.y = vBoxMin.z = bigNum
                      vBoxMax.x = vBoxMax.y = vBoxMax.z = 0 - bigNum
                  Severity: Minor
                  Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 1 hr to fix

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

                      addVertexToGeo(geoOut, vAdd) {
                        let entry
                        const oneHynberes = 0.01
                        const n815851 = 815851
                        const n37633 = 37633
                    Severity: Minor
                    Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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

                    Avoid deeply nested control flow statements.
                    Open

                                if (i0 < 0) {
                                  break
                                }
                    Severity: Major
                    Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (dist2 < probeSpRad2) {
                                    distToSphere = Math.sqrt(dist2)
                                    distToBorder = -(distToSphere - probeSphereRadius)
                                    innerBlockWorkAround()
                                  } // if (dist from corner point to sphere center more 2 radiuses)
                      Severity: Major
                      Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 45 mins to fix

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

                          _innerBuild() {
                            let ok
                            const expandFactor = 1.2
                        
                            // performance test
                        Severity: Minor
                        Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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

                        Avoid deeply nested control flow statements.
                        Open

                                    if (cube.pointsValuesLinear[cubeValuesIndex + i] < 0.0) {
                                      bitsInside |= 1 << i
                                    }
                        Severity: Major
                        Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if (!this.addTriangle(vaEdges[i0], vaEdges[i1], vaEdges[i2])) {
                                        return 0 - 2
                                      }
                          Severity: Major
                          Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if (val < corners[ind]) {
                                          corners[ind] = val
                                        }
                            Severity: Major
                            Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 45 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                  if (
                                    a0 === null ||
                                    a1 === null ||
                                    a2 === null ||
                                    a0.srcAtom === null ||
                              Severity: Major
                              Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js - About 40 mins to fix

                                Function _fromGeo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  _fromGeo(geoOut) {
                                    let colors = null
                                    const positions = utils.allocateTyped(
                                      Float32Array,
                                      (1 + 2) * geoOut._numVertices
                                Severity: Minor
                                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.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

                                Similar blocks of code found in 3 locations. Consider refactoring.
                                Open

                                    const ix = Math.floor(
                                      (hashResolution * (vAdd.x - this.vBoxMin.x)) /
                                        (this.vBoxMax.x + oneHynberes - this.vBoxMin.x)
                                    )
                                Severity: Major
                                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js and 2 other locations - About 1 hr to fix
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 627..630
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 631..634

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 63.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 3 locations. Consider refactoring.
                                Open

                                    const iy = Math.floor(
                                      (hashResolution * (vAdd.y - this.vBoxMin.y)) /
                                        (this.vBoxMax.y + oneHynberes - this.vBoxMin.y)
                                    )
                                Severity: Major
                                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js and 2 other locations - About 1 hr to fix
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 623..626
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 631..634

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 63.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 3 locations. Consider refactoring.
                                Open

                                    const iz = Math.floor(
                                      (hashResolution * (vAdd.z - this.vBoxMin.z)) /
                                        (this.vBoxMax.z + oneHynberes - this.vBoxMin.z)
                                    )
                                Severity: Major
                                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js and 2 other locations - About 1 hr to fix
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 623..626
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 627..630

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 63.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 2 locations. Consider refactoring.
                                Open

                                        const dot2 = v.x * v.x + v.y * v.y + v.z * v.z
                                Severity: Minor
                                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js and 1 other location - About 30 mins to fix
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 541..541

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 45.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 2 locations. Consider refactoring.
                                Open

                                              vDif.x * vDif.x + vDif.y * vDif.y + vDif.z * vDif.z
                                Severity: Minor
                                Found in packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js and 1 other location - About 30 mins to fix
                                packages/miew/src/gfx/geometries/SSIsosurfaceGeometry.js on lines 652..652

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 45.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                There are no issues that match your filters.

                                Category
                                Status