src/models/models.stack.js

Summary

Maintainability
F
1 wk
Test Coverage

ModelsStack has 100 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class ModelsStack extends ModelsBase {
  /**
   * Models Stack constructor
   */
  constructor() {
Severity: Major
Found in src/models/models.stack.js - About 1 day to fix

    File models.stack.js has 779 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /** * Imports ***/
    import { Matrix4 } from 'three/src/math/Matrix4';
    import { Vector3 } from 'three/src/math/Vector3';
    import { RGBFormat, RGBAFormat } from 'three/src/constants';
    
    
    Severity: Major
    Found in src/models/models.stack.js - About 1 day to fix

      Function _packTo8Bits has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        _packTo8Bits(channels, frame, textureSize, startVoxel, stopVoxel) {
          const packed = {
            textureType: null,
            data: null,
          };
      Severity: Minor
      Found in src/models/models.stack.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 _packTo8Bits has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _packTo8Bits(channels, frame, textureSize, startVoxel, stopVoxel) {
          const packed = {
            textureType: null,
            data: null,
          };
      Severity: Major
      Found in src/models/models.stack.js - About 3 hrs to fix

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

          prepareSegmentation() {
            // store frame and do special pre-processing
            this._frameSegment = this._frame;
            let mergedFrames = [];
        
        
        Severity: Minor
        Found in src/models/models.stack.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 prepare has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          prepare() {
            // if segmentation, merge some frames...
            if (this._modality === 'SEG') {
              this.prepareSegmentation();
            }
        Severity: Minor
        Found in src/models/models.stack.js - About 1 hr to fix

          Function prepareSegmentation has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            prepareSegmentation() {
              // store frame and do special pre-processing
              this._frameSegment = this._frame;
              let mergedFrames = [];
          
          
          Severity: Minor
          Found in src/models/models.stack.js - About 1 hr to fix

            Function constructor has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor() {
                super();
            
                this._uid = null;
                this._stackID = -1;
            Severity: Minor
            Found in src/models/models.stack.js - About 1 hr to fix

              Function pack has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                pack() {
                  // Get total number of voxels
                  const nbVoxels = this._dimensionsIJK.x * this._dimensionsIJK.y * this._dimensionsIJK.z;
              
                  // Packing style
              Severity: Minor
              Found in src/models/models.stack.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if (
                      this._stackID === stack.stackID &&
                      this._numberOfFrames === 1 &&
                      stack._numberOfFrames === 1 &&
                      this._frame[0].columns === stack.frame[0].columns &&
                Severity: Critical
                Found in src/models/models.stack.js - About 1 hr to fix

                  Function orderFrames has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    orderFrames() {
                      // order the frames based on theirs dimension indices
                      // first index is the most important.
                      // 1,1,1,1 will be first
                      // 1,1,2,1 will be next
                  Severity: Minor
                  Found in src/models/models.stack.js - About 1 hr to fix

                    Function _orderFrameOnDimensionIndicesArraySort has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      _orderFrameOnDimensionIndicesArraySort(a, b) {
                        if (
                          'dimensionIndexValues' in a &&
                          Object.prototype.toString.call(a.dimensionIndexValues) === '[object Array]' &&
                          'dimensionIndexValues' in b &&
                    Severity: Minor
                    Found in src/models/models.stack.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 zSpacing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      zSpacing() {
                        if (this._numberOfFrames > 1) {
                          if (this._frame[0].pixelSpacing && this._frame[0].pixelSpacing[2]) {
                            this._spacing.z = this._frame[0].pixelSpacing[2];
                          } else {
                    Severity: Minor
                    Found in src/models/models.stack.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 pack has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      pack() {
                        // Get total number of voxels
                        const nbVoxels = this._dimensionsIJK.x * this._dimensionsIJK.y * this._dimensionsIJK.z;
                    
                        // Packing style
                    Severity: Minor
                    Found in src/models/models.stack.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

                    Avoid deeply nested control flow statements.
                    Open

                          for (let i = startVoxel; i < stopVoxel; i++) {
                            frameIndex = ~~(i / frameDimension);
                            inFrameIndex = i % frameDimension;
                    
                            let raw = frame[frameIndex].pixelData[inFrameIndex] + offset;
                    Severity: Major
                    Found in src/models/models.stack.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              if (!Number.isNaN(raw)) {
                                data[4 * packIndex] = raw & 0x000000ff;
                                data[4 * packIndex + 1] = (raw >>> 8) & 0x000000ff;
                                data[4 * packIndex + 2] = (raw >>> 16) & 0x000000ff;
                                data[4 * packIndex + 3] = (raw >>> 24) & 0x000000ff;
                      Severity: Major
                      Found in src/models/models.stack.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                            } else if (bitsAllocated === 8 && channels === 3) {
                              let data = new Uint8Array(textureSize * textureSize * 3);
                        
                              for (let i = startVoxel; i < stopVoxel; i++) {
                                frameIndex = ~~(i / frameDimension);
                        Severity: Major
                        Found in src/models/models.stack.js - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                              } else if (
                                this._frame[0].imagePosition &&
                                this._frame[0].imageOrientation &&
                                this._frame[1] &&
                                this._frame[1].imagePosition &&
                          Severity: Major
                          Found in src/models/models.stack.js - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                if (
                                  index.x >= 0 &&
                                  index.y >= 0 &&
                                  index.z >= 0 &&
                                  index.x < dimensions.x &&
                            Severity: Major
                            Found in src/models/models.stack.js - About 40 mins to fix

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

                                orderFrames() {
                                  // order the frames based on theirs dimension indices
                                  // first index is the most important.
                                  // 1,1,1,1 will be first
                                  // 1,1,2,1 will be next
                              Severity: Minor
                              Found in src/models/models.stack.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 worldBoundingBox has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                worldBoundingBox() {
                                  let bbox = [
                                    Number.POSITIVE_INFINITY,
                                    Number.NEGATIVE_INFINITY,
                                    Number.POSITIVE_INFINITY,
                              Severity: Minor
                              Found in src/models/models.stack.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 packEchos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                packEchos() {
                                  // 4 echo times...
                                  let echos = 4;
                                  let packedEcho = [];
                                  for (let i = 0; i < this._frame.length; i += echos) {
                              Severity: Minor
                              Found in src/models/models.stack.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

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

                                  this._halfDimensionsIJK = new Vector3(
                                    this._dimensionsIJK.x / 2,
                                    this._dimensionsIJK.y / 2,
                                    this._dimensionsIJK.z / 2
                                  );
                              Severity: Minor
                              Found in src/models/models.stack.js and 1 other location - About 55 mins to fix
                              src/models/models.stack.js on lines 278..282

                              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 53.

                              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

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

                                  this._halfDimensionsIJK = new Vector3(
                                    this._dimensionsIJK.x / 2,
                                    this._dimensionsIJK.y / 2,
                                    this._dimensionsIJK.z / 2
                                  );
                              Severity: Minor
                              Found in src/models/models.stack.js and 1 other location - About 55 mins to fix
                              src/models/models.stack.js on lines 198..202

                              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 53.

                              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

                                    if (!Number.isNaN(max)) {
                                      this._minMax[1] = Math.max(this._minMax[1], max);
                                    }
                              Severity: Minor
                              Found in src/models/models.stack.js and 1 other location - About 40 mins to fix
                              src/models/models.stack.js on lines 405..407

                              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 49.

                              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

                                    if (!Number.isNaN(min)) {
                                      this._minMax[0] = Math.min(this._minMax[0], min);
                                    }
                              Severity: Minor
                              Found in src/models/models.stack.js and 1 other location - About 40 mins to fix
                              src/models/models.stack.js on lines 410..412

                              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 49.

                              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