NatLibFi/marc-record-validators-melinda

View on GitHub
src/isbn-issn.js

Summary

Maintainability
C
1 day
Test Coverage

Function fix has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function fix(record) {
    getRelevantFields(record).forEach(field => {
      if (field.tag === '020') {
        field.subfields.forEach(subfield => fixField020Subfield(field, subfield));
        return;
Severity: Major
Found in src/isbn-issn.js - About 2 hrs to fix

    Function fixField020Subfield has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function fixField020Subfield(field, subfield) {
          split020A(); // subfield and field are in the scope
          addHyphens(subfield);
          handleInvalidIsbn(field, subfield); // remove 020$a, add 020$z, Do this last, as it uses deletion
          return;
    Severity: Major
    Found in src/isbn-issn.js - About 2 hrs to fix

      Function getRelevantFields has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function getRelevantFields(record) {
          //return record.get(/^(?:020|022)$/u).filter(field => {
          return record.fields.filter(field => {
            if (!field.subfields) {
              return false;
      Severity: Minor
      Found in src/isbn-issn.js - About 1 hr to fix

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

          function validate(record) {
            const fields = getRelevantFields(record);
        
            if (fields.length === 0) {
              return {valid: true};
        Severity: Minor
        Found in src/isbn-issn.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

                  return !validateISSN(subfield.value);
          Severity: Major
          Found in src/isbn-issn.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return false;
            Severity: Major
            Found in src/isbn-issn.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status