NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 822 of 822 total issues

File ending-punctuation.spec.js has 2265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {MarcRecord} from '@natlibfi/marc-record';
import validatorFactory from '../src/ending-punctuation';

Severity: Major
Found in src/ending-punctuation.spec.js - About 6 days to fix

    Function default has a Cognitive Complexity of 156 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function () {
    
      return {
        description, validate, fix
      };
    Severity: Minor
    Found in src/addMissingField338.js - About 3 days 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 default has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function () {
    
      return {
        description, validate, fix
      };
    Severity: Minor
    Found in src/addMissingField336.js - About 2 days 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 field-exclusion.spec.js has 796 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import chai from 'chai';
    import chaiAsPromised from 'chai-as-promised';
    import {MarcRecord} from '@natlibfi/marc-record';
    import validatorFactory from '../src/field-exclusion';
    
    
    Severity: Major
    Found in src/field-exclusion.spec.js - About 1 day to fix

      Function validateField has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
      Open

      function validateField(field, linkedTag, fix, message) {
        // This is used to find last subfield that should have punctuation
        function findLastSubfield(field) {
          const subfields = field.subfields.filter(sf => isNaN(sf.code) && 'value' in sf);
          return subfields.slice(-1).shift();
      Severity: Minor
      Found in src/ending-punctuation.js - About 1 day 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 default has 315 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function () {
      
        return {
          description, validate, fix
        };
      Severity: Major
      Found in src/addMissingField338.js - About 1 day to fix

        File ending-punctuation-conf.js has 680 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Const finnishTerms = ['ysa', 'yso', 'kassu', 'seko', 'valo', 'kulo', 'puho', 'oiko', 'mero', 'liito', 'fast', 'allars', 'kaunokki'];
        const finnishTerms = [
          /^ysa$/u,
          /^yso$/u,
          /^kassu$/u,
        Severity: Major
        Found in src/ending-punctuation-conf.js - About 1 day to fix

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

                expect(record.fields).to.eql([
                  {
                    tag: '001',
                    value: '100'
                  },
          Severity: Major
          Found in src/sort-tags.spec.js and 1 other location - About 1 day to fix
          src/sort-tags.spec.js on lines 103..182

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

          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

                  fields: [
                    {
                      tag: '001',
                      value: '100'
                    },
          Severity: Major
          Found in src/sort-tags.spec.js and 1 other location - About 1 day to fix
          src/sort-tags.spec.js on lines 185..264

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

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

          export default async function (tagPattern, treshold = 0.9) {
            const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/item-language');
            const cldFactory = await loadCLD();
          
            if (tagPattern instanceof RegExp) {
          Severity: Minor
          Found in src/item-language.js - About 1 day 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 field-structure.spec.js has 550 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import chai from 'chai';
          import chaiAsPromised from 'chai-as-promised';
          import {MarcRecord} from '@natlibfi/marc-record';
          import validatorFactory from '../src/field-structure';
          
          
          Severity: Major
          Found in src/field-structure.spec.js - About 1 day to fix

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

            export default function () {
              function readPunctuationRulesFromJSON(recordType) {
                const json = getRules(recordType);
                const rules = json.filter(row => row.selector !== '').map(row => {
                  const {selector, namePortion, description, portion, preceedingPunctuation, exceptions} = row;
            Severity: Major
            Found in src/punctuation/index.js - About 1 day to fix

              Function default has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function () {
                function readPunctuationRulesFromJSON(recordType) {
                  const json = getRules(recordType);
                  const rules = json.filter(row => row.selector !== '').map(row => {
                    const {selector, namePortion, description, portion, preceedingPunctuation, exceptions} = row;
              Severity: Minor
              Found in src/punctuation/index.js - About 7 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

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

                  const recordBroken = new MarcRecord({
                    leader: '',
                    fields: [
                      {
                        tag: '245',
              Severity: Major
              Found in src/ending-punctuation.spec.js and 1 other location - About 7 hrs to fix
              src/ending-punctuation.spec.js on lines 43..71

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

              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 recordInvalid = new MarcRecord({
                    leader: '',
                    fields: [
                      {
                        tag: '245',
              Severity: Major
              Found in src/ending-punctuation.spec.js and 1 other location - About 7 hrs to fix
              src/ending-punctuation.spec.js on lines 72..100

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

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

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

                File subfield-exclusion.spec.js has 453 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import {expect} from 'chai';
                //import chaiAsPromised from 'chai-as-promised';
                import {MarcRecord} from '@natlibfi/marc-record';
                import validatorFactory from '../src/subfield-exclusion';
                
                
                Severity: Minor
                Found in src/subfield-exclusion.spec.js - About 6 hrs to fix

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

                  async function callback({getFixture, enabled = true, fix = true}) {
                    if (enabled === false) {
                      debug('TEST SKIPPED!');
                      return;
                    }
                  Severity: Major
                  Found in src/sortFields.spec.js and 25 other locations - About 6 hrs to fix
                  src/field-008-18-34-character-groups.spec.js on lines 33..52
                  src/field-505-separators.spec.js on lines 33..52
                  src/field-521-fix.spec.js on lines 33..52
                  src/fix-country-codes.spec.js on lines 33..52
                  src/fixRelatorTerms.spec.js on lines 33..52
                  src/indicator-fixes.spec.js on lines 33..52
                  src/mergeField500Lisapainokset.spec.js on lines 33..52
                  src/mergeRelatorTermFields.spec.js on lines 33..52
                  src/multiple-subfield-0.spec.js on lines 33..52
                  src/normalize-dashes.spec.js on lines 33..52
                  src/normalize-identifiers.spec.js on lines 33..52
                  src/normalize-qualifying-information.spec.js on lines 33..52
                  src/normalize-utf8-diacritics.spec.js on lines 33..52
                  src/punctuation.spec.js on lines 33..52
                  src/punctuation2.spec.js on lines 33..52
                  src/reindexSubfield6OccurenceNumbers.spec.js on lines 33..52
                  src/removeDuplicateDataFields.spec.js on lines 33..52
                  src/removeInferiorDataFields.spec.js on lines 33..52
                  src/resolveOrphanedSubfield6s.spec.js on lines 33..52
                  src/sanitize-vocabulary-source-codes.spec.js on lines 33..52
                  src/sortRelatorTerms.spec.js on lines 33..52
                  src/stripPunctuation.spec.js on lines 33..52
                  src/subfieldValueNormalizations.spec.js on lines 33..52
                  src/sync-007-and-300.spec.js on lines 33..52
                  src/update-field-540.spec.js on lines 33..52

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

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

                  async function callback({getFixture, enabled = true, fix = false}) {
                    if (enabled === false) {
                      debug('TEST SKIPPED!');
                      return;
                    }
                  Severity: Major
                  Found in src/field-505-separators.spec.js and 25 other locations - About 6 hrs to fix
                  src/field-008-18-34-character-groups.spec.js on lines 33..52
                  src/field-521-fix.spec.js on lines 33..52
                  src/fix-country-codes.spec.js on lines 33..52
                  src/fixRelatorTerms.spec.js on lines 33..52
                  src/indicator-fixes.spec.js on lines 33..52
                  src/mergeField500Lisapainokset.spec.js on lines 33..52
                  src/mergeRelatorTermFields.spec.js on lines 33..52
                  src/multiple-subfield-0.spec.js on lines 33..52
                  src/normalize-dashes.spec.js on lines 33..52
                  src/normalize-identifiers.spec.js on lines 33..52
                  src/normalize-qualifying-information.spec.js on lines 33..52
                  src/normalize-utf8-diacritics.spec.js on lines 33..52
                  src/punctuation.spec.js on lines 33..52
                  src/punctuation2.spec.js on lines 33..52
                  src/reindexSubfield6OccurenceNumbers.spec.js on lines 33..52
                  src/removeDuplicateDataFields.spec.js on lines 33..52
                  src/removeInferiorDataFields.spec.js on lines 33..52
                  src/resolveOrphanedSubfield6s.spec.js on lines 33..52
                  src/sanitize-vocabulary-source-codes.spec.js on lines 33..52
                  src/sortFields.spec.js on lines 33..52
                  src/sortRelatorTerms.spec.js on lines 33..52
                  src/stripPunctuation.spec.js on lines 33..52
                  src/subfieldValueNormalizations.spec.js on lines 33..52
                  src/sync-007-and-300.spec.js on lines 33..52
                  src/update-field-540.spec.js on lines 33..52

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

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

                  async function callback({getFixture, enabled = true, fix = false}) {
                    if (enabled === false) {
                      debug('TEST SKIPPED!');
                      return;
                    }
                  Severity: Major
                  Found in src/stripPunctuation.spec.js and 25 other locations - About 6 hrs to fix
                  src/field-008-18-34-character-groups.spec.js on lines 33..52
                  src/field-505-separators.spec.js on lines 33..52
                  src/field-521-fix.spec.js on lines 33..52
                  src/fix-country-codes.spec.js on lines 33..52
                  src/fixRelatorTerms.spec.js on lines 33..52
                  src/indicator-fixes.spec.js on lines 33..52
                  src/mergeField500Lisapainokset.spec.js on lines 33..52
                  src/mergeRelatorTermFields.spec.js on lines 33..52
                  src/multiple-subfield-0.spec.js on lines 33..52
                  src/normalize-dashes.spec.js on lines 33..52
                  src/normalize-identifiers.spec.js on lines 33..52
                  src/normalize-qualifying-information.spec.js on lines 33..52
                  src/normalize-utf8-diacritics.spec.js on lines 33..52
                  src/punctuation.spec.js on lines 33..52
                  src/punctuation2.spec.js on lines 33..52
                  src/reindexSubfield6OccurenceNumbers.spec.js on lines 33..52
                  src/removeDuplicateDataFields.spec.js on lines 33..52
                  src/removeInferiorDataFields.spec.js on lines 33..52
                  src/resolveOrphanedSubfield6s.spec.js on lines 33..52
                  src/sanitize-vocabulary-source-codes.spec.js on lines 33..52
                  src/sortFields.spec.js on lines 33..52
                  src/sortRelatorTerms.spec.js on lines 33..52
                  src/subfieldValueNormalizations.spec.js on lines 33..52
                  src/sync-007-and-300.spec.js on lines 33..52
                  src/update-field-540.spec.js on lines 33..52

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

                  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