NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 1,132 of 1,132 total issues

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

      const recordInvalid = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '567',
Severity: Major
Found in src/ending-punctuation.spec.js and 8 other locations - About 1 hr to fix
src/ending-punctuation.spec.js on lines 279..289
src/ending-punctuation.spec.js on lines 373..383
src/ending-punctuation.spec.js on lines 815..825
src/ending-punctuation.spec.js on lines 922..932
src/ending-punctuation.spec.js on lines 1103..1113
src/ending-punctuation.spec.js on lines 1164..1174
src/ending-punctuation.spec.js on lines 1400..1410
src/field-exclusion.spec.js on lines 432..442

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 60.

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 9 locations. Consider refactoring.
Open

      const recordValidWithoutY = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '242',
Severity: Major
Found in src/ending-punctuation.spec.js and 8 other locations - About 1 hr to fix
src/ending-punctuation.spec.js on lines 373..383
src/ending-punctuation.spec.js on lines 815..825
src/ending-punctuation.spec.js on lines 922..932
src/ending-punctuation.spec.js on lines 1103..1113
src/ending-punctuation.spec.js on lines 1164..1174
src/ending-punctuation.spec.js on lines 1400..1410
src/ending-punctuation.spec.js on lines 1440..1450
src/field-exclusion.spec.js on lines 432..442

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 60.

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 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 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 optionalSubfieldComparison has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function optionalSubfieldComparison(originalBaseField, originalSourceField, keySubfieldsAsString) {
        // Here "optional subfield" means a subfield, that needs not to be present, but if present, it must be identical...
        // (Think of a better name...)
        // We use clones here, since these changes done below are not intented to appear on the actual records.
        const field1 = cloneAndNormalizeFieldForComparison(originalBaseField);
      Severity: Minor
      Found in src/merge-fields/counterpartField.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 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

              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 - 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 - 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 - 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

                  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

                  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 - 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} 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 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 2 locations. Consider refactoring.
                  Open

                  export function nvdebugFieldArray(fields, prefix = '  ', func = undefined) {
                    fields.forEach(field => nvdebug(`${prefix}${fieldToString(field)}`, func));
                  }
                  Severity: Major
                  Found in src/utils.js and 1 other location - About 1 hr to fix
                  src/utils.js on lines 219..221

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language