Function controlSubfield9PermitsMerge
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
function controlSubfield9PermitsMerge(baseField, sourceField) {
const baseFieldSubfields9 = baseField.subfields.filter(sf => sf.code === '9');
const sourceFieldSubfields9 = sourceField.subfields.filter(sf => sf.code === '9');
//nvdebug('CHECK $9', debugDev);
- 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 controlSubfield9PermitsMerge
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
function controlSubfield9PermitsMerge(baseField, sourceField) {
const baseFieldSubfields9 = baseField.subfields.filter(sf => sf.code === '9');
const sourceFieldSubfields9 = sourceField.subfields.filter(sf => sf.code === '9');
//nvdebug('CHECK $9', debugDev);
Function keepOrDropPreventsMerge
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function keepOrDropPreventsMerge() {
const keepOrDrop1 = baseFieldSubfields9.filter(sf => subfieldHasKeepOrDrop(sf));
const keepOrDrop2 = sourceFieldSubfields9.filter(sf => subfieldHasKeepOrDrop(sf));
if (keepOrDrop1.length === 0 && keepOrDrop2.length === 0) {
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return true;
Function controlSubfieldsPermitMerge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function controlSubfieldsPermitMerge(baseField, sourceField) {
// Check $w, $0, $1, $2 (which isn't an identifier per se, but the sama logic can be applied)
if (!controlSubfieldsContainingIdentifier.every(subfieldCode => controlSubfieldContainingIdentifierPermitsMerge(baseField, sourceField, subfieldCode))) {
//debug(' control subfields with identifiers failed');
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 controlSubfieldContainingIdentifierPermitsMerge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function controlSubfieldContainingIdentifierPermitsMerge(field1, field2, subfieldCode) {
if (!fieldHasSubfield(field1, subfieldCode, null) || !fieldHasSubfield(field2, subfieldCode, null)) {
return true;
}
- 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 controlSubfield5PermitsMerge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function controlSubfield5PermitsMerge(field1, field2) {
// field1.$5 XOR field2.$5 means false, NEITHER and BOTH mean true, regardless of value
if (!fieldHasSubfield(field1, '5')) {
if (!fieldHasSubfield(field2, '5')) {
return true; // If neither one has $5, it's ok to merge
- 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"