NatLibFi/marc-record-validators-melinda

View on GitHub
src/merge-fields/mergeIndicator.js

Summary

Maintainability
D
2 days
Test Coverage

Function mergeIndicators has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
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.
  //
Severity: Minor
Found in src/merge-fields/mergeIndicator.js - About 1 day to fix

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

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.
  //
Severity: Major
Found in src/merge-fields/mergeIndicator.js - About 4 hrs to fix

    Function getIndicatorPreferredValues has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    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.
    Severity: Minor
    Found in src/merge-fields/mergeIndicator.js - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

                return cands;
      Severity: Major
      Found in src/merge-fields/mergeIndicator.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return [];
        Severity: Major
        Found in src/merge-fields/mergeIndicator.js - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status