NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 1,132 of 1,132 total issues

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

export default function () {
  return {
    description: 'Fix $e subfields in field [1678][01]0 and 720',
    validate, fix
  };
Severity: Minor
Found in src/fixRelatorTerms.js - About 1 hr to fix

    Function configMatchesSpec has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function configMatchesSpec(data, key, spec) {
        // Field not found in configuration spec
        if (!spec[key]) {
          throw new Error(`Configuration not valid - unidentified value: ${key}`);
        }
    Severity: Minor
    Found in src/field-exclusion.js - About 1 hr to fix

      Function fieldToChain has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function fieldToChain(field, record) {
        if (field.deleted || !field.subfields) {
          return [];
        }
        const chain = newGetAllLinkedFields(field, record, true, true);
      Severity: Minor
      Found in src/removeDuplicateDataFields.js - About 1 hr to fix

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

        export default function () {
          return {
            description: 'Reindex occurrence numbers in $6 subfield so that they start from 01 and end in NN',
            validate, fix
          };
        Severity: Minor
        Found in src/reindexSubfield6OccurenceNumbers.js - About 1 hr to fix

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

          export default function () {
            return {
              description: 'Handles subfields that ends with whitespace character',
              validate,
              fix
          Severity: Minor
          Found in src/ending-whitespace.js - About 1 hr to fix

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

              const f337 = {
                tag: '337',
                ind1: ' ',
                ind2: ' ',
                subfields: [
            Severity: Major
            Found in src/urn.spec.js and 1 other location - About 1 hr to fix
            src/access-rights.spec.js on lines 7..15

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

            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

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

              const f337 = {
                tag: '337',
                ind1: ' ',
                ind2: ' ',
                subfields: [
            Severity: Major
            Found in src/access-rights.spec.js and 1 other location - About 1 hr to fix
            src/urn.spec.js on lines 7..15

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

            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

            function fix521(field) {
              if (field.tag !== '521' || !field.subfields) {
                return field;
              }
              fixIndicator1(field);
            Severity: Minor
            Found in src/field-521-fix.js and 1 other location - About 55 mins to fix
            src/field-505-separators.js on lines 68..75

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

            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

              if (languages.includes('ger')) {
                const match = valueBeginsWithDeterminer(name, ['das ', 'der ', 'die ']);
                if (match) {
                  return `${match.length}`;
                }
            Severity: Minor
            Found in src/indicator-fixes.js and 1 other location - About 55 mins to fix
            src/indicator-fixes.js on lines 88..93

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

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

            export function map336CodeToTerm(code, catLang = 'fin') {
              const [mapping] = field336Mappings.filter(m => m.code === code);
              return map33XCodeToTerm(mapping, catLang);
            }
            Severity: Major
            Found in src/field33XUtils.js and 2 other locations - About 55 mins to fix
            src/field33XUtils.js on lines 122..125
            src/field33XUtils.js on lines 127..130

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

            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

            function fix505(field) {
              if (field.tag !== '505' || !field.subfields) {
                return field;
              }
              field505FixSubfieldTRG(field);
            Severity: Minor
            Found in src/field-505-separators.js and 1 other location - About 55 mins to fix
            src/field-521-fix.js on lines 84..91

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

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

            export function map337CodeToTerm(code, catLang = 'fin') {
              const [mapping] = field337Mappings.filter(m => m.code === code);
              return map33XCodeToTerm(mapping, catLang);
            }
            Severity: Major
            Found in src/field33XUtils.js and 2 other locations - About 55 mins to fix
            src/field33XUtils.js on lines 117..120
            src/field33XUtils.js on lines 127..130

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

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

            export function map338CodeToTerm(code, catLang = 'fin') {
              const [mapping] = field338Mappings.filter(m => m.code === code);
              return map33XCodeToTerm(mapping, catLang);
            }
            Severity: Major
            Found in src/field33XUtils.js and 2 other locations - About 55 mins to fix
            src/field33XUtils.js on lines 117..120
            src/field33XUtils.js on lines 122..125

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

            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

              if (languages.includes('eng')) {
                const match = valueBeginsWithDeterminer(name, ['a ', 'an ', 'the ']);
                if (match) {
                  return `${match.length}`;
                }
            Severity: Minor
            Found in src/indicator-fixes.js and 1 other location - About 55 mins to fix
            src/indicator-fixes.js on lines 102..107

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

            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 sortByOccurrenceNumber has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function sortByOccurrenceNumber(fieldA, fieldB) { // Sort by subfield $6
            
              function fieldGetOccurrenceNumber(field) { // should this function be exported? (based on validator sortRelatorFields.js)
                if (!field.subfields) {
                  return 0;
            Severity: Minor
            Found in src/sortFields.js - About 55 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

            Function recordResetSubfield6OccurrenceNumbers has a Cognitive Complexity of 9 (exceeds 5 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 55 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

            Function newGetAllLinkedFields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function newGetAllLinkedFields(field, record, useSixes = true, useEights = true) {
              removeLinkNotes(record); // should be clear, but let's play safe
            
              /* eslint-disable */
              field.linkNote = LINK_ROOT;
            Severity: Minor
            Found in src/removeDuplicateDataFields.js - About 55 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

            Function preferSourceCorporateName has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function preferSourceCorporateName(field, candSubfield, pair) {
              if (candSubfield.code !== 'a' || !['110', '610', '710', '810'].includes(field.tag)) {
                return false;
              }
              nvdebug(`CORP base '${pair.value}' vs '${candSubfield.value}'`, debugDev);
            Severity: Minor
            Found in src/merge-fields/mergeSubfield.js - About 55 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

            Function preferQualifierVersion has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function preferQualifierVersion(field, candSubfield, relevantSubfields) {
              if (!canContainOptionalQualifier(field.tag, candSubfield.code)) { // currently only 300$a and 776$i can prefer source...
                return false;
              }
            
            
            Severity: Minor
            Found in src/merge-fields/mergeSubfield.js - About 55 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

            Function fieldHandleDuplicateDatafields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function fieldHandleDuplicateDatafields(field, record) {
              const chain = fieldToChain(field, record);
              nvdebug(` TRY TO HANDLE DUPLICATES OF '${fieldsToString(chain)}'`);
            
              if (chain.length === 0) {
            Severity: Minor
            Found in src/removeDuplicateDataFields.js - About 55 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

            Severity
            Category
            Status
            Source
            Language