src/merge-fields/mergeIndicator.js
Function mergeIndicators
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
Open
export function mergeIndicators(toField, fromField, config) {
// NB! For non-filing indicators we deem that bigger is better. This is a bit quick'n'dirty, as usual.
// We could and should checks the relevant article length (using language information whilst doing it).
// However, this is a task for record internal fixer, not 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"
Further reading
Function mergeIndicators
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function mergeIndicators(toField, fromField, config) {
// NB! For non-filing indicators we deem that bigger is better. This is a bit quick'n'dirty, as usual.
// We could and should checks the relevant article length (using language information whilst doing it).
// However, this is a task for record internal fixer, not merge.
//
Function getIndicatorPreferredValues
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getIndicatorPreferredValues(tag, indicatorNumber, config) {
const cands = getIndicatorPreferredValuesForGivenTag(tag, indicatorNumber, config);
// More complex systems where multiple indicators have same priority are objects.
// Example: field 506 might return {"0": 1, "1": 1, " ": 2}
// Here indicator values '0' and '1' share top priority 1, and '#' is of lesser importance, namely 2.
Avoid too many return
statements within this function. Open
Open
return cands;
Avoid too many return
statements within this function. Open
Open
return [];