Showing 10 of 20 total issues
Function isCnpj
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const isCnpj = cnpjNumber => {
const cnpjRegex = /^(\d{2}[\.]?\d{3}[\.]?\d{3}[\/]?\d{4}[-]?\d{2})$/;
if (cnpjRegex.test(cnpjNumber)) {
const cnpj = cnpjNumber.replace(/\.|-|\//g, '');
if (cnpj === '00000000000000' ||
- 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 isCpf
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const isCpf = cpfNumber => {
const cpfRegex = /^(\d{3}[\.]?\d{3}[\.]?\d{3}[-]?\d{2})$/;
if (cpfRegex.test(cpfNumber)) {
const cpf = cpfNumber.replace(/\.|-/g, '');
if (cpf === '00000000000' ||
- 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 (cnpj === '00000000000000' ||
cnpj === '11111111111111' ||
cnpj === '22222222222222' ||
cnpj === '33333333333333' ||
cnpj === '44444444444444' ||
Consider simplifying this complex logical expression. Open
if (cpf === '00000000000' ||
cpf === '11111111111' ||
cpf === '22222222222' ||
cpf === '33333333333' ||
cpf === '44444444444' ||
Function isCnpj
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const isCnpj = cnpjNumber => {
const cnpjRegex = /^(\d{2}[\.]?\d{3}[\.]?\d{3}[\/]?\d{4}[-]?\d{2})$/;
if (cnpjRegex.test(cnpjNumber)) {
const cnpj = cnpjNumber.replace(/\.|-|\//g, '');
if (cnpj === '00000000000000' ||
Function isCpf
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const isCpf = cpfNumber => {
const cpfRegex = /^(\d{3}[\.]?\d{3}[\.]?\d{3}[-]?\d{2})$/;
if (cpfRegex.test(cpfNumber)) {
const cpf = cpfNumber.replace(/\.|-/g, '');
if (cpf === '00000000000' ||
Function validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
(...fn) =>
value => {
if (isNil(value)) {
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
Avoid too many return
statements within this function. Open
return Boolean(value);
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return false;