ivmartel/dwv

View on GitHub
src/image/iterator.js

Summary

Maintainability
F
5 days
Test Coverage

File iterator.js has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {Index} from '../math/index';
import {Point2D} from '../math/point';

// doc imports
/* eslint-disable no-unused-vars */
Severity: Minor
Found in src/image/iterator.js - About 7 hrs to fix

    Function getSliceIterator has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getSliceIterator(
      image, position, isRescaled, viewOrientation) {
      const size = image.getGeometry().getSize();
      // zero-ify non direction index
      let dirMax2Index = 2;
    Severity: Minor
    Found in src/image/iterator.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 getSliceIterator has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getSliceIterator(
      image, position, isRescaled, viewOrientation) {
      const size = image.getGeometry().getSize();
      // zero-ify non direction index
      let dirMax2Index = 2;
    Severity: Major
    Found in src/image/iterator.js - About 3 hrs to fix

      Function range3d has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function range3d(dataAccessor, start, maxIter, increment,
        blockMaxIter, blockIncrement, reverse1, reverse2, isPlanar) {
        const iters = [];
        if (isPlanar) {
          iters.push(range(
      Severity: Major
      Found in src/image/iterator.js - About 2 hrs to fix

        Function getVariableRegionSliceIterator has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function getVariableRegionSliceIterator(
          image, index, isRescaled, regions) {
          if (image.getNumberOfComponents() !== 1) {
            throw new Error('Unsupported number of components for region iterator: ' +
              image.getNumberOfComponents());
        Severity: Major
        Found in src/image/iterator.js - About 2 hrs to fix

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

          export function range(dataAccessor, start, maxIter, increment,
            blockMaxIter, blockIncrement, reverse1, reverse2) {
            if (typeof reverse1 === 'undefined') {
              reverse1 = false;
            }
          Severity: Minor
          Found in src/image/iterator.js - About 1 hr to fix

            Function range has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            export function range(dataAccessor, start, maxIter, increment,
              blockMaxIter, blockIncrement, reverse1, reverse2) {
              if (typeof reverse1 === 'undefined') {
                reverse1 = false;
              }
            Severity: Minor
            Found in src/image/iterator.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 simpleRange3d has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function simpleRange3d(
              dataAccessor, start, end, increment, isPlanar) {
              if (typeof increment === 'undefined') {
                increment = 1;
              }
            Severity: Minor
            Found in src/image/iterator.js - About 1 hr to fix

              Function getRegionSliceIterator has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function getRegionSliceIterator(
                image, index, isRescaled, min, max) {
                if (image.getNumberOfComponents() !== 1) {
                  throw new Error('Unsupported number of components for region iterator: ' +
                    image.getNumberOfComponents());
              Severity: Minor
              Found in src/image/iterator.js - About 1 hr to fix

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

                export function getVariableRegionSliceIterator(
                  image, index, isRescaled, regions) {
                  if (image.getNumberOfComponents() !== 1) {
                    throw new Error('Unsupported number of components for region iterator: ' +
                      image.getNumberOfComponents());
                Severity: Minor
                Found in src/image/iterator.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 rangeRegions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function rangeRegions(
                  dataAccessor, start, end, increment, regions) {
                  let nextIndex = start;
                  let regionCount = 0;
                  let regionElementCount = 0;
                Severity: Minor
                Found in src/image/iterator.js - About 1 hr to fix

                  Function range3d has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  export function range3d(dataAccessor, start, maxIter, increment,
                    blockMaxIter, blockIncrement, reverse1, reverse2, isPlanar) {
                  Severity: Major
                  Found in src/image/iterator.js - About 1 hr to fix

                    Function range has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    export function range(dataAccessor, start, maxIter, increment,
                      blockMaxIter, blockIncrement, reverse1, reverse2) {
                    Severity: Major
                    Found in src/image/iterator.js - About 1 hr to fix

                      Function getRange has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          dataAccessor, start, maxIter, increment,
                          blockMaxIter, blockIncrement, reverse1, reverse2) {
                      Severity: Major
                      Found in src/image/iterator.js - About 1 hr to fix

                        Function rangeRegions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function rangeRegions(
                          dataAccessor, start, end, increment, regions) {
                          let nextIndex = start;
                          let regionCount = 0;
                          let regionElementCount = 0;
                        Severity: Minor
                        Found in src/image/iterator.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

                              if (dirMax0.index === 0) {
                                // xzy
                                rangeObj = getRange(dataAccessor,
                                  start, maxIter, 1, ncols, sliceSize, reverse1, reverse2);
                              } else {
                        Severity: Major
                        Found in src/image/iterator.js - About 45 mins to fix

                          Function rangeRegion has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            dataAccessor, start, end, increment, regionSize, regionOffset) {
                          Severity: Minor
                          Found in src/image/iterator.js - About 45 mins to fix

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

                              dataAccessor, start, end, increment, isPlanar) {
                            Severity: Minor
                            Found in src/image/iterator.js - About 35 mins to fix

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

                                dataAccessor, start, end, increment, regions) {
                              Severity: Minor
                              Found in src/image/iterator.js - About 35 mins to fix

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

                                  image, index, isRescaled, min, max) {
                                Severity: Minor
                                Found in src/image/iterator.js - About 35 mins to fix

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

                                  export function simpleRange3d(
                                    dataAccessor, start, end, increment, isPlanar) {
                                    if (typeof increment === 'undefined') {
                                      increment = 1;
                                    }
                                  Severity: Minor
                                  Found in src/image/iterator.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 getRegionSliceIterator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  export function getRegionSliceIterator(
                                    image, index, isRescaled, min, max) {
                                    if (image.getNumberOfComponents() !== 1) {
                                      throw new Error('Unsupported number of components for region iterator: ' +
                                        image.getNumberOfComponents());
                                  Severity: Minor
                                  Found in src/image/iterator.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 2 locations. Consider refactoring.
                                  Open

                                      if (dirMax2.index === 2) {
                                        // axial
                                        maxIter = ncols * nrows;
                                        if (dirMax0.index === 0) {
                                          // xyz
                                  Severity: Major
                                  Found in src/image/iterator.js and 1 other location - About 2 hrs to fix
                                  src/image/iterator.js on lines 465..479

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

                                  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

                                      } else if (dirMax2.index === 1) {
                                        // coronal
                                        maxIter = nslices * ncols;
                                        if (dirMax0.index === 0) {
                                          // xzy
                                  Severity: Major
                                  Found in src/image/iterator.js and 1 other location - About 2 hrs to fix
                                  src/image/iterator.js on lines 441..479

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

                                  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 3 locations. Consider refactoring.
                                  Open

                                    if (isRescaled) {
                                      dataAccessor = function (offset) {
                                        return image.getRescaledValueAtOffset(offset);
                                      };
                                    } else {
                                  Severity: Major
                                  Found in src/image/iterator.js and 2 other locations - About 1 hr to fix
                                  src/image/iterator.js on lines 402..410
                                  src/image/iterator.js on lines 520..528

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

                                  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 3 locations. Consider refactoring.
                                  Open

                                    if (isRescaled) {
                                      dataAccessor = function (offset) {
                                        return image.getRescaledValueAtOffset(offset);
                                      };
                                    } else {
                                  Severity: Major
                                  Found in src/image/iterator.js and 2 other locations - About 1 hr to fix
                                  src/image/iterator.js on lines 520..528
                                  src/image/iterator.js on lines 578..586

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

                                  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 3 locations. Consider refactoring.
                                  Open

                                    if (isRescaled) {
                                      dataAccessor = function (offset) {
                                        return image.getRescaledValueAtOffset(offset);
                                      };
                                    } else {
                                  Severity: Major
                                  Found in src/image/iterator.js and 2 other locations - About 1 hr to fix
                                  src/image/iterator.js on lines 402..410
                                  src/image/iterator.js on lines 578..586

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

                                  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