aureooms/js-prime

View on GitHub

Showing 17 of 17 total issues

Function __eratosthenes23__ has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

export function __eratosthenes23__(alloc, fill, get, gothrough, usqrt) {
    const first = 5;

    const eratosthenes23 = function (n, callback) {
        let j;
Severity: Minor
Found in src/sieve/eratosthenes23.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 __eratosthenes23__ has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function __eratosthenes23__(alloc, fill, get, gothrough, usqrt) {
    const first = 5;

    const eratosthenes23 = function (n, callback) {
        let j;
Severity: Major
Found in src/sieve/eratosthenes23.js - About 2 hrs to fix

    Function eratosthenes23 has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const eratosthenes23 = function (n, callback) {
            let j;
            let p;
            let l;
    
    
    Severity: Major
    Found in src/sieve/eratosthenes23.js - About 2 hrs to fix

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

                  if (get(sieve, i)) {
                      p = itop231(i);
      
                      callback(p);
      
      
      Severity: Major
      Found in src/sieve/eratosthenes23.js and 1 other location - About 2 hrs to fix
      src/sieve/eratosthenes23.js on lines 76..85

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

      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 (get(sieve, i)) {
                      p = itop230(i);
      
                      callback(p);
      
      
      Severity: Major
      Found in src/sieve/eratosthenes23.js and 1 other location - About 2 hrs to fix
      src/sieve/eratosthenes23.js on lines 93..102

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

      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

              for (let i = ptoi2(first); i < m; ++i) {
                  if (get(sieve, i)) {
                      const p = itop2(i);
                      callback(p);
                      gothrough(sieve, ptoi2(p * p), size, p);
      Severity: Major
      Found in src/sieve/eratosthenes2.js and 1 other location - About 2 hrs to fix
      src/sieve/eratosthenes.js on lines 23..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 75.

      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

              for (let i = ptoi(first); i < m; ++i) {
                  if (get(sieve, i)) {
                      const p = itop(i);
                      callback(p);
                      gothrough(sieve, ptoi(p * p), size, p);
      Severity: Major
      Found in src/sieve/eratosthenes.js and 1 other location - About 2 hrs to fix
      src/sieve/eratosthenes2.js on lines 29..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 75.

      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 __eratosthenes2__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      export function __eratosthenes2__(alloc, fill, get, gothrough, usqrt) {
          const first = 3;
      
          const eratosthenes2 = function (n, callback) {
              if (n <= 2) {
      Severity: Minor
      Found in src/sieve/eratosthenes2.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 __eratosthenes__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      export function __eratosthenes__(alloc, fill, get, gothrough, usqrt) {
          const first = 2;
      
          const eratosthenes = function (n, callback) {
              if (n <= 2) {
      Severity: Minor
      Found in src/sieve/eratosthenes.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 __eratosthenes2__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function __eratosthenes2__(alloc, fill, get, gothrough, usqrt) {
          const first = 3;
      
          const eratosthenes2 = function (n, callback) {
              if (n <= 2) {
      Severity: Minor
      Found in src/sieve/eratosthenes2.js - About 1 hr to fix

        Function stoa has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function stoa(i, n) {
            let line = (i / n) | 0;
            let col = i % n;
        
            if (n % 2 === 0) {
        Severity: Minor
        Found in src/ulam/stoa.js - About 1 hr to fix

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

          export function __eratosthenes__(alloc, fill, get, gothrough, usqrt) {
          Severity: Minor
          Found in src/sieve/eratosthenes.js - About 35 mins to fix

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

            export function __eratosthenes23__(alloc, fill, get, gothrough, usqrt) {
            Severity: Minor
            Found in src/sieve/eratosthenes23.js - About 35 mins to fix

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

              export function __eratosthenes2__(alloc, fill, get, gothrough, usqrt) {
              Severity: Minor
              Found in src/sieve/eratosthenes2.js - About 35 mins to fix

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

                        for (let i = m; i < size; ++i) {
                            if (get(sieve, i)) {
                                callback(itop2(i));
                            }
                        }
                Severity: Minor
                Found in src/sieve/eratosthenes2.js and 1 other location - About 35 mins to fix
                src/sieve/eratosthenes.js on lines 31..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 46.

                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

                        for (let i = m; i < size; ++i) {
                            if (get(sieve, i)) {
                                callback(itop(i));
                            }
                        }
                Severity: Minor
                Found in src/sieve/eratosthenes.js and 1 other location - About 35 mins to fix
                src/sieve/eratosthenes2.js on lines 37..41

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

                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 atos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export function atos(i, n) {
                    const s = Math.sqrt(i) | 0;
                    const l = s;
                    const r = s + 1;
                    const L = l * l;
                Severity: Minor
                Found in src/ulam/atos.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

                Severity
                Category
                Status
                Source
                Language