JoeKarlsson/data-structures

View on GitHub

Showing 50 of 50 total issues

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

  findMax() {
    const node = this.root;
    const traverse = ( node ) => {
      return !node.right ? node.value : traverse( node.right );
    };
Severity: Major
Found in search/binary-search-tree.js and 1 other location - About 1 hr to fix
search/binary-search-tree.js on lines 185..191

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

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 swap = (array, index1, index2) => {
    // store a tmp variable at pos index2
    const tmp = array[index2];

    // set value  of index2 to our value at index
Severity: Major
Found in sorting/selectionsort.js and 2 other locations - About 1 hr to fix
sorting/insertionsort.js on lines 3..12
sorting/quicksort.js on lines 5..15

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

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 swap = ( array, index1, index2 ) => {
    // store a tmp variable at pos index2
    const tmp = array[index2];

    // set value  of index2 to our value at index
Severity: Major
Found in sorting/insertionsort.js and 2 other locations - About 1 hr to fix
sorting/quicksort.js on lines 5..15
sorting/selectionsort.js on lines 3..12

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

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 swap = ( array, index1, index2 ) => {

    // store a tmp variable at pos index2
    const tmp = array[index2];

Severity: Major
Found in sorting/quicksort.js and 2 other locations - About 1 hr to fix
sorting/insertionsort.js on lines 3..12
sorting/selectionsort.js on lines 3..12

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

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

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

const quickModule = (() => {
  // Private Methods and variables

  // swap method because its used multiple times
  const swap = ( array, index1, index2 ) => {
Severity: Minor
Found in sorting/quicksort.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 FFT_Recursive has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function FFT_Recursive(input, inverse) {
  const n = input.length;

  if (n === 1) {
    return input;
Severity: Minor
Found in fast-fourier-transforms/fft.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 FFT_2_Iterative has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function FFT_2_Iterative(input, inverse) {
  const n = input.length;

  const output = BitReverseComplexArray(input);
  const output_r = output.real;
Severity: Minor
Found in fast-fourier-transforms/fft.js - About 1 hr to fix

    Function neighbors has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      neighbors(node) {
        const ret = [];
        const x = node.x;
        const y = node.y;
        const grid = this.grid;
    Severity: Minor
    Found in graph/gridGraph.js - About 1 hr to fix

      Function nodeAverages has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        nodeAverages() {
          const node = this.root;
          const result = {};
          const depthAverages = [];
      
      
      Severity: Minor
      Found in search/binary-search-tree.js - About 1 hr to fix

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

            if (grid[x + 1] && grid[x + 1][y]) {
              ret.push(grid[x + 1][y]);
            }
        Severity: Major
        Found in graph/gridGraph.js and 1 other location - About 1 hr to fix
        graph/gridGraph.js on lines 50..52

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

        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 (grid[x - 1] && grid[x - 1][y]) {
              ret.push(grid[x - 1][y]);
            }
        Severity: Major
        Found in graph/gridGraph.js and 1 other location - About 1 hr to fix
        graph/gridGraph.js on lines 55..57

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

        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

        Function mergeModule has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const mergeModule = ( () => {
          // used to merge all of our pieces back together after recursively separating the array
          const merge = ( left, right ) => {
            // initialize array to return
            const result = [];
        Severity: Minor
        Found in sorting/mergesort.js - About 1 hr to fix

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

          const swap = ( arr, i1, i2 ) => {
            const tmp = arr[i1];
            arr[i1] = arr[i2];
            arr[i2] = tmp;
            return arr;
          Severity: Minor
          Found in sorting/bubble-recursive.js and 1 other location - About 55 mins to fix
          sorting/bubblesort.js on lines 2..7

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

          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

            const swap = ( arr, i1, i2) => {
              const tmp = arr[i1];
              arr[i1] = arr[i2];
              arr[i2] = tmp;
              return arr;
          Severity: Minor
          Found in sorting/bubblesort.js and 1 other location - About 55 mins to fix
          sorting/bubble-recursive.js on lines 1..6

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

          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

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

          const bubbleModule = (() => {
            const swap = ( arr, i1, i2) => {
              const tmp = arr[i1];
              arr[i1] = arr[i2];
              arr[i2] = tmp;
          Severity: Minor
          Found in sorting/bubblesort.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

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

            insert(currentNode) {
              const value = currentNode.value;
          
              const traverse = (node) => {
                if (value > node.value) {
          Severity: Minor
          Found in search/binary-search-tree.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

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

              for (let i = 0; i < this.nodes.length; i++) {
                astar.cleanNode(this.nodes[i]);
              }
          Severity: Minor
          Found in graph/gridGraph.js and 1 other location - About 45 mins to fix
          graph/gridGraph.js on lines 33..35

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

          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

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

          function FFT_2_Iterative(input, inverse) {
            const n = input.length;
          
            const output = BitReverseComplexArray(input);
            const output_r = output.real;
          Severity: Minor
          Found in fast-fourier-transforms/fft.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 (
                        neighbor.h < closestNode.h ||
                        (neighbor.h === closestNode.h && neighbor.g < closestNode.g)
                      ) {
                        closestNode = neighbor;
          Severity: Major
          Found in shortest-path/aStar.js - About 45 mins to fix

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

                for (let i = 0; i < this.dirtyNodes.length; i++) {
                  astar.cleanNode(this.dirtyNodes[i]);
                }
            Severity: Minor
            Found in graph/gridGraph.js and 1 other location - About 45 mins to fix
            graph/gridGraph.js on lines 27..29

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

            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

            Severity
            Category
            Status
            Source
            Language