nodef/extra-number

View on GitHub

Showing 7 of 20 total issues

File index.ts has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// #region METHODS
// ===============

// #region ABOUT
// -------------
Severity: Minor
Found in src/index.ts - About 3 hrs to fix

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

    export function maxPrimeFactor(x: number): number {
      var x = Math.abs(x), a = 0;
      // 1. GPF of 2, 3 is the number itself.
      if (x<=1) return 0;
      if (x<=3) return x;
    Severity: Minor
    Found in src/index.ts - 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 minPrimeFactor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export function minPrimeFactor(x: number): number {
      var x = Math.abs(x);
      // 1. LPF of 2, 3 is the number itself.
      if (x<=1) return 0;
      if (x<=3) return x;
    Severity: Minor
    Found in src/index.ts - 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 fromRomanNumerals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function fromRomanNumerals(txt: string): number {
      var s = ROMAN_SYMBOLS.length-1;
      var n = txt.search(/^\s*-/) >= 0, a = 0;
      var txt = txt.replace(/\W/g, '').toUpperCase();
      for (var i=0, I=txt.length; i<I;  i += ROMAN_SYMBOLS[s].length) {
    Severity: Minor
    Found in src/index.ts - About 35 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 too many return statements within this function.
    Open

        if (x % (i+1)===0) return i+1;
    Severity: Major
    Found in src/index.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          if (x % (i-1)===0) return i-1;
      Severity: Major
      Found in src/index.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return x;
        Severity: Major
        Found in src/index.ts - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language