NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 830 of 830 total issues

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

export default function () {

  return {
    description: 'Normalizes indicator values',
    validate, fix
Severity: Minor
Found in src/indicator-fixes.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

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

      export function removeDuplicateSubfield8Chains(record, fix = true) {
      
        // Seen $8 subsfields in various fields:
        // 161 700
        // 17 710
      Severity: Minor
      Found in src/removeDuplicateDataFields.js - About 1 hr to fix

        Function deriveInferiorChains has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function deriveInferiorChains(fields, record) {
          //nvdebug(`======= GOT ${fields.length} FIELDS TO CHAINIFY`);
          const hash = {};
        
          fields.forEach(f => fieldToChainToDeletables(f));
        Severity: Minor
        Found in src/removeInferiorDataFields.js - About 1 hr to fix

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

          export default function () {
          
            return {
              // Fixes MELINDA-8740
              description: 'Normalize qualifying information (020$q, 015$q, 024$q, 028$q)',
          Severity: Minor
          Found in src/normalize-qualifying-information.js - About 1 hr to fix

            Function swapESubfields has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function swapESubfields(field) {
              if (!field.subfields) {
                return;
              }
            
            
            Severity: Minor
            Found in src/sortRelatorTerms.js - About 1 hr to fix

              Similar blocks of code found in 10 locations. Consider refactoring.
              Open

                    try {
                      await validatorFactory(config);
                    } catch (error) {
                      expect(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: code');
                    }
              Severity: Major
              Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
              src/field-exclusion.spec.js on lines 49..53
              src/field-exclusion.spec.js on lines 62..66
              src/field-exclusion.spec.js on lines 92..96
              src/field-exclusion.spec.js on lines 109..113
              src/field-exclusion.spec.js on lines 124..128
              src/field-exclusion.spec.js on lines 142..146
              src/field-exclusion.spec.js on lines 161..165
              src/field-exclusion.spec.js on lines 179..183
              src/field-exclusion.spec.js on lines 198..202

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 59.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 10 locations. Consider refactoring.
              Open

                    try {
                      await validatorFactory(config);
                    } catch (error) {
                      expect(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: tag');
                    }
              Severity: Major
              Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
              src/field-exclusion.spec.js on lines 62..66
              src/field-exclusion.spec.js on lines 77..81
              src/field-exclusion.spec.js on lines 92..96
              src/field-exclusion.spec.js on lines 109..113
              src/field-exclusion.spec.js on lines 124..128
              src/field-exclusion.spec.js on lines 142..146
              src/field-exclusion.spec.js on lines 161..165
              src/field-exclusion.spec.js on lines 179..183
              src/field-exclusion.spec.js on lines 198..202

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 59.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function recordResetSubfield6OccurrenceNumbers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function recordResetSubfield6OccurrenceNumbers(record) { // Remove gaps
                /* eslint-disable */
                let currentInt = 1;
                let oldtoNewCache = {};
              
              
              Severity: Minor
              Found in src/reindexSubfield6OccurenceNumbers.js - About 1 hr to fix

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration array not provided');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 179..183
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - subfield: /9/,/^(?!FENNI<KEEP>).*$/ not object');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 179..183
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - subfield: /9/ not object');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 179..183
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: tag');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 179..183
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - unidentified value: unidentified');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 179..183

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    const messages = nonValidFields.flatMap(({tag, subfields}) => subfields.map(sf => `Field ${tag} subfield $${sf.code} ends with whitespace`));
                Severity: Major
                Found in src/ending-whitespace.js and 1 other location - About 1 hr to fix
                src/non-breaking-space.js on lines 16..16

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: value');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 179..183
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    const messages = nonValidFields.flatMap(({tag, subfields}) => subfields.map(sf => `Field ${tag} subfield $${sf.code} contains non-breaking space character(s)`));
                Severity: Major
                Found in src/non-breaking-space.js and 1 other location - About 1 hr to fix
                src/ending-whitespace.js on lines 16..16

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: code');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 109..113
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 10 locations. Consider refactoring.
                Open

                      try {
                        await validatorFactory(config);
                      } catch (error) {
                        expect(error).to.be.an('error').with.property('message', 'Configuration not valid - excluded element');
                      }
                Severity: Major
                Found in src/field-exclusion.spec.js and 9 other locations - About 1 hr to fix
                src/field-exclusion.spec.js on lines 49..53
                src/field-exclusion.spec.js on lines 62..66
                src/field-exclusion.spec.js on lines 77..81
                src/field-exclusion.spec.js on lines 92..96
                src/field-exclusion.spec.js on lines 124..128
                src/field-exclusion.spec.js on lines 142..146
                src/field-exclusion.spec.js on lines 161..165
                src/field-exclusion.spec.js on lines 179..183
                src/field-exclusion.spec.js on lines 198..202

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export default function () {
                
                  return {
                    description: 'Normalize " ; " separators as " -- "',
                    validate, fix
                Severity: Minor
                Found in src/field-505-separators.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language