NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 830 of 830 total issues

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

export function precomposeFinnishLetters(value = '') {
  return value.
    replace(/å/gu, 'å').
    replace(/ä/gu, 'ä').
    replace(/ö/gu, 'ö').
Severity: Major
Found in src/normalize-utf8-diacritics.js and 1 other location - About 1 hr to fix
src/addMissingField338.js on lines 38..40

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

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 trimExtent(value) {
    return value.replace(/\([^)]*\)/gu, '').replace(/\[[^\]*]\]/gu, '').replace(/[0-9]/gu, '').replace(/^ +/gu, '').replace(/[ :;+]+$/gu, '').replace(/  +/gu, ' ');
  }
Severity: Major
Found in src/addMissingField338.js and 1 other location - About 1 hr to fix
src/normalize-utf8-diacritics.js on lines 80..88

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

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

export default function () {

  return {
    description: 'Normalize various dashes to "-"',
    validate, fix
Severity: Minor
Found in src/normalize-dashes.js - About 1 hr to fix

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

    export default function () {
    
      return {
        description: 'Fix various subfield internal values',
        validate, fix
    Severity: Minor
    Found in src/subfieldValueNormalizations.js - About 1 hr to fix

      Function guessUsingFileFields has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function guessUsingFileFields() {
            const characteristics = record.get('(256|516)').map(f => fieldToString(f));
            if (characteristics.some(str => str.match(/(?:ohjelma)/gui))) {
              return ['cop'];
            }
      Severity: Minor
      Found in src/addMissingField336.js - About 1 hr to fix

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

        export default function () {
        
          return {
            description: 'Generic normalization of latin UTF-8 diacritics. Precompose Finnish å, ä and ö. Decompose others.',
            validate, fix
        Severity: Minor
        Found in src/normalize-utf8-diacritics.js - About 1 hr to fix

          Function normalizeQualifyingInformationField has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function normalizeQualifyingInformationField(field) {
            if (!['015', '020', '024', '028'].includes(field.tag) || !field.subfields) {
              return;
            }
          
          
          Severity: Minor
          Found in src/normalize-qualifying-information.js - About 1 hr to fix

            Function sortByRelatorTerm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function sortByRelatorTerm(fieldA, fieldB) {
              //if (!['600', '610', '611', '630', '700', '710', '711', '730', '800', '810', '811', '830'].includes(fieldA.tag)) {
              if (!['700', '710', '711', '730'].includes(fieldA.tag)) {
                return 0;
              }
            Severity: Minor
            Found in src/sortFields.js - About 1 hr 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 swapSubfields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function swapSubfields(field, sortOrder) {
              if (!field.subfields) {
                return;
              }
            
            
            Severity: Minor
            Found in src/sortSubfields.js - About 1 hr 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 9 locations. Consider refactoring.
            Open

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function isSubfield6Pair has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export function isSubfield6Pair(field, otherField) {
              // No need to log this:
              //nvdebug(`LOOK for $6-pair:\n ${fieldToString(field)}\n ${fieldToString(otherField)}`);
              if (!fieldHasValidSubfield6(field) || !fieldHasValidSubfield6(otherField)) {
                return false;
            Severity: Minor
            Found in src/subfield6Utils.js - About 1 hr 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 9 locations. Consider refactoring.
            Open

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function recordDisambiguateSharedSubfield6OccurrenceNumbers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function recordDisambiguateSharedSubfield6OccurrenceNumbers(record) {
              const sharedOccurrenceNumberFields = recordGetSharedOccurrenceNumbers(record);
              if (sharedOccurrenceNumberFields.length < 2) {
                return;
              }
            Severity: Minor
            Found in src/reindexSubfield6OccurenceNumbers.js - About 1 hr 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 9 locations. Consider refactoring.
            Open

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language