NatLibFi/marc-record-validators-melinda

View on GitHub
src/cyrillux-usemarcon-replacement.js

Summary

Maintainability
D
1 day
Test Coverage

Function field260To264s has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

function field260To264s(field, record) { // might be generic... if so, move to utils...
  // As per my quick reading of usemarcon-cyrillux
  if (field.tag !== '260') {
    return;
  }
Severity: Minor
Found in src/cyrillux-usemarcon-replacement.js - About 4 hrs 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

File cyrillux-usemarcon-replacement.js has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
*  cyrillux-usemarcon-replacement.js -- implement and improve https://github.com/NatLibFi/USEMARCON-Cyrillux/tree/master
*
* Author(s): Nicholas Volk <nicholas.volk@helsinki.fi>
*
Severity: Minor
Found in src/cyrillux-usemarcon-replacement.js - About 2 hrs to fix

    Function field260To264s has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function field260To264s(field, record) { // might be generic... if so, move to utils...
      // As per my quick reading of usemarcon-cyrillux
      if (field.tag !== '260') {
        return;
      }
    Severity: Major
    Found in src/cyrillux-usemarcon-replacement.js - About 2 hrs to fix

      Function default has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function () {
        return {
          description, fix, validate
        };
      
      
      Severity: Major
      Found in src/cyrillux-usemarcon-replacement.js - About 2 hrs to fix

        Function finnishTranslationsAndMappings has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function finnishTranslationsAndMappings(value) {
          return value.replace('analog', 'analoginen').
            replace('approximately', 'noin').
            replace('audio discs', 'äänilevyä').
            replace('black and white', 'mustavalkoinen').
        Severity: Minor
        Found in src/cyrillux-usemarcon-replacement.js - About 1 hr to fix

          Function realFix has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function realFix(record) {
              // Fix leader: standard fixes + update LDR/17 to '4'
              fixLeader(record);
              record.leader = `${record.leader.substring(0, 17)}4${record.leader.substring(18, 24)}`; // eslint-disable-line functional/immutable-data
          
          
          Severity: Minor
          Found in src/cyrillux-usemarcon-replacement.js - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                return subfield.value;
            Severity: Major
            Found in src/cyrillux-usemarcon-replacement.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return subfield.value.replace(/\b[Ss]\. ?a\./u, 'julkaisuaika tuntematon');
              Severity: Major
              Found in src/cyrillux-usemarcon-replacement.js - About 30 mins to fix

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

                function translateFieldToFinnish(field) {
                  if (!['020', '300'].includes(field.tag)) {
                    return;
                  }
                  field.subfields?.forEach(sf => translateSubfieldToFinnish(sf));
                Severity: Minor
                Found in src/cyrillux-usemarcon-replacement.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