se-panfilov/jsvat

View on GitHub

Showing 18 of 38 total issues

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

function _isPhysicalPerson(vat: string, physicalMultipliers: ReadonlyArray<number>): boolean {
  // 10 digit VAT code - see if it relates to a standard physical person
  if (/^\d\d[0-5]\d[0-3]\d\d{4}$/.test(vat)) {
    // Check month
    const month = Number(vat.slice(2, 4));
Severity: Minor
Found in src/lib/countries/bulgaria.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 calcFn has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  calcFn: (vat: string): boolean => {
    let total = 0;

    // Differentiate between legal entities and natural bodies. For the latter we simply check that
    // the first six digits correspond to valid DDMMYY dates.
Severity: Minor
Found in src/lib/countries/latvia.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 isStandardOrCommercialNumber has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function isStandardOrCommercialNumber(vat: string, multipliers: ReadonlyArray<number>): boolean {
  let total = 0;

  // 0 VAT numbers disallowed!
  if (Number(vat.slice(0)) === 0) return false;
Severity: Minor
Found in src/lib/countries/unitedKingdom.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 _check12DigitINN has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function _check12DigitINN(vat: string, rules: Rules): boolean {
  let total1 = 0;
  let total2 = 0;

  if (vat.length === 12) {
Severity: Minor
Found in src/lib/countries/russia.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 extractAndMultiplyByCounter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function extractAndMultiplyByCounter(vat: string, total: number): number {
  let result = total;
  for (let i = 0; i < 8; i++) {
    let temp = Number(vat.charAt(i));
    if (i % 2 === 0) {
Severity: Minor
Found in src/lib/countries/cyprus.ts - About 1 hr to fix

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

    function isStandardOrCommercialNumber(vat: string, multipliers: ReadonlyArray<number>): boolean {
      let total = 0;
    
      // 0 VAT numbers disallowed!
      if (Number(vat.slice(0)) === 0) return false;
    Severity: Minor
    Found in src/lib/countries/unitedKingdom.ts - About 1 hr to fix

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

        calcFn: (vat: string): boolean => {
          let total = 0;
          let temp;
      
          // The last three digits are the issuing office, and cannot exceed more 201, unless 999 or 888
      Severity: Minor
      Found in src/lib/countries/italy.ts - 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

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

        calcFn: (vat: string): boolean => {
          const { typeFormats, multipliers } = ireland.rules;
          if (!typeFormats || !typeFormats.first) return false;
          let total: string | number = 0;
      
      
      Severity: Minor
      Found in src/lib/countries/ireland.ts - 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

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

      function isIndividualType2(
        vat: string,
        multipliers: ReadonlyArray<number>,
        additional: ReadonlyArray<RegExp>,
        lookup?: ReadonlyArray<number>
      Severity: Minor
      Found in src/lib/countries/czechRepublic.ts - 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

      Consider simplifying this complex logical expression.
      Open

          if ((month > 0 && month < 13) || (month > 20 && month < 33) || (month > 40 && month < 53)) {
            let total = _increase2(0, vat, 0, 9, physicalMultipliers);
            // Establish check digit.
            total = total % 11;
            if (total === 10) total = 0;
      Severity: Major
      Found in src/lib/countries/bulgaria.ts - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

          if (
            checkDigit === Number(vat.slice(7, 9)) &&
            no < 9990001 &&
            (no < 100000 || no > 999999) &&
            (no < 9490001 || no > 9700000)
        Severity: Major
        Found in src/lib/countries/unitedKingdom.ts - About 40 mins to fix

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

          function _increase(value: number, vat: string, from: number, to: number, incr: number): number {
          Severity: Minor
          Found in src/lib/countries/bulgaria.ts - About 35 mins to fix

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

            function _increase2(value: number, vat: string, from: number, to: number, multipliers: ReadonlyArray<number>): number {
            Severity: Minor
            Found in src/lib/countries/bulgaria.ts - About 35 mins to fix

              Function isLegalEntities has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function isLegalEntities(vat: string, multipliers: ReadonlyArray<number>, additional: ReadonlyArray<RegExp>): boolean {
                let total = 0;
                if (additional[0].test(vat)) {
                  // Extract the next digit and multiply by the counter.
                  for (let i = 0; i < 7; i++) {
              Severity: Minor
              Found in src/lib/countries/czechRepublic.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

                  return false;
              Severity: Major
              Found in src/lib/countries/spain.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    if (additional[3].test(vat)) return isPersonalKtoX(vat);
                Severity: Major
                Found in src/lib/countries/spain.ts - About 30 mins to fix

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

                  function extractAndMultiplyByCounter(vat: string, total: number): number {
                    let result = total;
                    for (let i = 0; i < 8; i++) {
                      let temp = Number(vat.charAt(i));
                      if (i % 2 === 0) {
                  Severity: Minor
                  Found in src/lib/countries/cyprus.ts - 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 calcFn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    calcFn: (input: string): boolean => {
                      const vat = input.replace(/[\ \-\_]/g, '').toUpperCase();
                  
                      const { additional, multipliers } = netherlands.rules;
                      if (!additional) return false;
                  Severity: Minor
                  Found in src/lib/countries/netherlands.ts - 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