NatLibFi/marc-record-validators-melinda

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

Summary

Maintainability
A
3 hrs
Test Coverage

Function valueCarriesMeaning has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function valueCarriesMeaning(tag, subfieldCode, value) {
  // Some data is pretty meaningless and as meaningless is pretty close to nothing, this meaningless data should no prevent merge.
  // The list below is incomples (swedish translations etc)
  if (tag === '260' || tag === '264') {
    // We drop these, instead of normalizing, as KV does not put this information in place...
Severity: Minor
Found in src/merge-fields/worldKnowledge.js - About 1 hr 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

Avoid too many return statements within this function.
Open

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

    Avoid too many return statements within this function.
    Open

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

      Avoid too many return statements within this function.
      Open

          return `3. painos`;
      Severity: Major
      Found in src/merge-fields/worldKnowledge.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return `4. painos`;
        Severity: Major
        Found in src/merge-fields/worldKnowledge.js - About 30 mins to fix

          Function normalizeEditionStatement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function normalizeEditionStatement(originalValue) {
            const value = originalValue;
          
            // As normalization tries to translate things info Finnish, use this for similarity check only!
            if (value.match(/^[1-9][0-9]*(?:\.|:a|nd|rd|st|th) (?:ed\.?|edition|p\.?|painos|uppl\.?|upplagan)[.\]]*$/ui)) {
          Severity: Minor
          Found in src/merge-fields/worldKnowledge.js - About 25 mins 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

          There are no issues that match your filters.

          Category
          Status