src/lib/countries/bulgaria.ts
Function _isPhysicalPerson
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
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
Consider simplifying this complex logical expression. Open
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;
Function _increase2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function _increase2(value: number, vat: string, from: number, to: number, multipliers: ReadonlyArray<number>): number {
Function _increase
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function _increase(value: number, vat: string, from: number, to: number, incr: number): number {