se-panfilov/jsvat

View on GitHub
src/lib/countries/bulgaria.ts

Summary

Maintainability
A
3 hrs
Test Coverage

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

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

    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 _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

        There are no issues that match your filters.

        Category
        Status