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));
- Read upRead up
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.
- Read upRead up
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;
- Read upRead up
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) {
- Read upRead up
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) {
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;
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
- Read upRead up
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;
- Read upRead up
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>
- Read upRead up
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;
Consider simplifying this complex logical expression. Open
if (
checkDigit === Number(vat.slice(7, 9)) &&
no < 9990001 &&
(no < 100000 || no > 999999) &&
(no < 9490001 || no > 9700000)
Function _increase
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function _increase(value: number, vat: string, from: number, to: number, incr: number): number {
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 {
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++) {
- Read upRead up
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;
Avoid too many return
statements within this function. Open
if (additional[3].test(vat)) return isPersonalKtoX(vat);
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) {
- Read upRead up
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;
- Read upRead up
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"