NatLibFi/marc-record-validators-melinda

View on GitHub

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

          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

              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

                  File fix-33X.js has 442 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  //import createDebugLogger from 'debug';
                  import clone from 'clone';
                  import {fieldToString, getCatalogingLanguage, nvdebug} from './utils';
                  import {map336CodeToTerm, map337CodeToTerm, map338CodeToTerm} from './field33XUtils';
                  
                  
                  Severity: Minor
                  Found in src/fix-33X.js - About 6 hrs to fix

                    File bib.js has 420 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    const bibRules =
                    [
                      {
                        selector: '[1678]00',
                        namePortion: '$a',
                    Severity: Minor
                    Found in src/punctuation/rules/bib.js - About 6 hrs to fix

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

                      export default function (isLegalDeposit = false, useMelindaTemp = true) {
                        const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:urn');
                        const debugData = debug.extend('data');
                      
                        // We should check that the f856 with URN has second indicator '0' (Resource), ' ' (No information provided) or '8' (No display constant generated)
                      Severity: Minor
                      Found in src/urn.js - About 5 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

                      Function validateField has 138 lines of code (exceeds 25 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: Major
                      Found in src/ending-punctuation.js - About 5 hrs to fix

                        Function deriveIndividualDeletables has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function deriveIndividualDeletables(record) {
                          const todoList = record.fields.map(f => fieldToString(f));
                          //const finishedRecord = encodingLevelIsBetterThanPrepublication(getEncodingLevel(record));
                        
                          const deletableStringsArray = processTodoList(todoList);
                        Severity: Minor
                        Found in src/removeInferiorDataFields.js - About 5 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

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

                        export default function () {
                        
                          return {
                            description, validate, fix
                          };
                        Severity: Minor
                        Found in src/fix-33X.js - About 5 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

                        File punctuation2.js has 381 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        /*
                        * punctuation.js -- try and fix a marc field punctuation
                        *
                        * Author(s): Nicholas Volk <nicholas.volk@helsinki.fi>
                        *
                        Severity: Minor
                        Found in src/punctuation2.js - About 5 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language