NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 1,132 of 1,132 total issues

Function normalPuncRules has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function normalPuncRules(subfield, punc, tag, checkEnd, overrideValidPuncMarks) {
Severity: Minor
Found in src/ending-punctuation.js - About 35 mins to fix

    Function mergeField2 has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function mergeField2(baseRecord, baseField, sourceField, config, candFieldPairs880 = []) {
    Severity: Minor
    Found in src/merge-fields/mergeField.js - About 35 mins to fix

      Function subfieldToNormalizedString has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function subfieldToNormalizedString(sf, tag, targetLinkingNumber = 0, normalizeOccurrenceNumber = false, normalizeEntryTagBoolean = false) {
      Severity: Minor
      Found in src/subfield6Utils.js - About 35 mins to fix

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

        function validLicenseInSubfieldC(subfieldC, license) {
          if (subfieldC.code !== 'c') {
            return false;
          }
          //nvdebug(`Compare ${subfieldC.value} vs ${license.license}`);
        Severity: Minor
        Found in src/update-field-540.js and 1 other location - About 35 mins to fix
        src/update-field-540.js on lines 61..67

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

        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 validUrlInSubfieldU(subfieldU, license) {
          if (subfieldU.code !== 'u') {
            return false;
          }
          //nvdebug(`Compare ${subfieldU.value} vs ${license.url}`);
        Severity: Minor
        Found in src/update-field-540.js and 1 other location - About 35 mins to fix
        src/update-field-540.js on lines 53..59

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

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

        function deriveIndividualNormalizedDeletables(record) { //  MET-461:
          const encodingLevel = getEncodingLevel(record);
          const recordIsFinished = encodingLevelIsBetterThanPrepublication(encodingLevel);
          const met495 = encodingLevel === '2' && record.fields.some(f => f.tag === '500' && fieldRefersToKoneellisestiTuotettuTietue(f));
          if (!recordIsFinished || met495) {
        Severity: Minor
        Found in src/removeInferiorDataFields.js - About 35 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 default has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function () {
          const PATTERN = Object.keys(MAP_CONVERSION).reduce((result, key, index, list) => index === list.length - 1 ? new RegExp(`${result}${key})`, 'u') : `${result}${key}|`, '(');
        
          return {
            description: 'Unicode decomposer',
        Severity: Minor
        Found in src/unicode-decomposition.js - About 35 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 getCounterpart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getCounterpart(baseRecord, sourceRecord, field, config) {
          // First get relevant candidate fields. Note that 1XX and corresponding 7XX are considered equal, and tags 260 and 264 are lumped together.
          // (<= Note that self-merge behaves differently from two records here.)
          // Hacks: 973 can merge with 773, 940 can merge with 240 (but not the other way around)
          //nvdebug(`COUNTERPART FOR '${fieldToString(field)}'?`, debugDev);
        Severity: Minor
        Found in src/merge-fields/counterpartField.js - About 35 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 splitPartData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function splitPartData(originalValue) {
          // This a very hacky function, but cand really help it, as the the data is very iffy as well...
          // Remove punctuation and brackets:
          const value = originalValue.replace(/[-.,:; ]+$/ui, '').replace(/^\[([0-9]+)\]$/ui, '$1'); // eslint-disable-line prefer-named-capture-group
        
        
        Severity: Minor
        Found in src/normalizeSubfieldValueForComparison.js - About 35 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 mergeSubfield has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function mergeSubfield(targetField, candSubfield) {
          // Replace existing subfield with the incoming field. These replacements are by name rather hacky...
          // Currenty we only select the better X00$d.
          // In future we might do more things here. Examples:
          // - "FOO" gets replaced by "Foo" in certain fields.
        Severity: Minor
        Found in src/merge-fields/mergeSubfield.js - About 35 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

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

            const subfieldValues2 = field2.subfields.filter(subfield => subfield.code === subfieldCode).map(sf => sf.value);
        Severity: Minor
        Found in src/merge-fields/counterpartField.js and 1 other location - About 35 mins to fix
        src/merge-fields/counterpartField.js on lines 310..310

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

        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 subfieldValues1 = field1.subfields.filter(subfield => subfield.code === subfieldCode).map(sf => sf.value);
        Severity: Minor
        Found in src/merge-fields/counterpartField.js and 1 other location - About 35 mins to fix
        src/merge-fields/counterpartField.js on lines 311..311

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

        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 (record.get('300').some(f => f.subfields.some(sf => sf.code === 'a' && sf.value.match(/mikrofilmikela/iu)))) {
        Severity: Minor
        Found in src/addMissingField338.js and 1 other location - About 35 mins to fix
        src/addMissingField338.js on lines 368..368

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

        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 (identifierFields.some(f => f.subfields.some(sf => sf.code === 'q' && sf.value.match(/\b(?:hard-?cover|kierre|nid|sid|kovakant|pehmeäkant|pärmar)/iu)))) {
        Severity: Minor
        Found in src/addMissingField338.js and 1 other location - About 35 mins to fix
        src/addMissingField338.js on lines 266..266

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

        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 fixSubfield(sf) {
            if (sf.code !== 'q') {
              return;
            }
            sf.value = normalizeValue(sf.value); // eslint-disable-line functional/immutable-data
        Severity: Minor
        Found in src/normalize-qualifying-information.js and 1 other location - About 35 mins to fix
        src/sanitize-vocabulary-source-codes.js on lines 59..64

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

        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 subfieldSanitizeVocabularySourceCode(subfield) {
            if (subfield.code !== '2') {
              return;
            }
            subfield.value = stringFixVocabularySourceCode(subfield.value); // eslint-disable-line functional/immutable-data
        Severity: Minor
        Found in src/sanitize-vocabulary-source-codes.js and 1 other location - About 35 mins to fix
        src/normalize-qualifying-information.js on lines 57..62

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

        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

        Avoid too many return statements within this function.
        Open

              return ['xxx']; // other
        Severity: Major
        Found in src/addMissingField336.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return 'ss';
          Severity: Major
          Found in src/addMissingField338.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return -1;
            Severity: Major
            Found in src/sortFields.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return processTodoList([tmp, ...stillToDo, ...moreToDo], [...deletables, tmp]);
              Severity: Major
              Found in src/removeInferiorDataFields.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language