Function deriveIndividualDeletables
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
function deriveIndividualDeletables(record) {
const todoList = record.fields.map(f => fieldToString(f));
//const finishedRecord = encodingLevelIsBetterThanPrepublication(getEncodingLevel(record));
const deletableStringsArray = processTodoList(todoList);
- 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 deriveIndividualDeletables
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
function deriveIndividualDeletables(record) {
const todoList = record.fields.map(f => fieldToString(f));
//const finishedRecord = encodingLevelIsBetterThanPrepublication(getEncodingLevel(record));
const deletableStringsArray = processTodoList(todoList);
File removeInferiorDataFields.js
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
import createDebugLogger from 'debug';
import {fieldToChain, sameField} from './removeDuplicateDataFields';
import {fieldGetOccurrenceNumberPairs, fieldHasValidSubfield6, fieldSevenToOneOccurrenceNumber, fieldsToNormalizedString} from './subfield6Utils';
import {fieldHasSubfield, fieldsToString, fieldToString, nvdebug, uniqArray} from './utils';
import {fieldHasValidSubfield8} from './subfield8Utils';
Function processTodoList
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processTodoList(thingsToDo, deletables = []) {
const [currString, ...stillToDo] = thingsToDo;
if (currString === undefined) {
return deletables;
Function removeInferiorChains
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export function removeInferiorChains(record, fix = true) {
const fields = record.fields.filter(f => isRelevantChain6(f, record));
//nvdebug(`WP2.0: GOT ${fields.length} chain(s)`);
const deletableChainsAsKeys = deriveInferiorChains(fields, record);
- 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 removeInferiorChains
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function removeInferiorChains(record, fix = true) {
const fields = record.fields.filter(f => isRelevantChain6(f, record));
//nvdebug(`WP2.0: GOT ${fields.length} chain(s)`);
const deletableChainsAsKeys = deriveInferiorChains(fields, record);
Function deriveInferiorChains
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function deriveInferiorChains(fields, record) {
//nvdebug(`======= GOT ${fields.length} FIELDS TO CHAINIFY`);
const hash = {};
fields.forEach(f => fieldToChainToDeletables(f));
Function deriveIndividualNormalizedDeletables
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function deriveIndividualNormalizedDeletables(record) { // MET-461:
const encodingLevel = getEncodingLevel(record);
const recordIsFinished = encodingLevelIsBetterThanPrepublication(encodingLevel);
const met495 = encodingLevel === '2' && record.fields.some(f => f.tag === '500' && fieldRefersToKoneellisestiTuotettuTietue(f));
if (!recordIsFinished || met495) {
- 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 processTodoList([...stillToDo, ...moreToDo], [...deletables, tmp, tmp2]);
Avoid too many return
statements within this function. Open
return processTodoList([...stillToDo, ...moreToDo], [...deletables, tmp]);
Avoid too many return
statements within this function. Open
return processTodoList([...stillToDo, ...moreToDo], newDeletables);
Avoid too many return
statements within this function. Open
return processTodoList([tmp, ...stillToDo, ...moreToDo], [...deletables, tmp]);
Avoid too many return
statements within this function. Open
return processTodoList([...stillToDo, ...moreToDo], newDeletables);
Function deriveInferiorChains
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function deriveInferiorChains(fields, record) {
//nvdebug(`======= GOT ${fields.length} FIELDS TO CHAINIFY`);
const hash = {};
fields.forEach(f => fieldToChainToDeletables(f));
- 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"