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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 54.

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

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

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

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

Refactorings

Further Reading

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

function sortByOccurrenceNumber(fieldA, fieldB) { // Sort by subfield $6

  function fieldGetOccurrenceNumber(field) { // should this function be exported? (based on validator sortRelatorFields.js)
    if (!field.subfields) {
      return 0;
Severity: Minor
Found in src/sortFields.js - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

export function recordResetSubfield6OccurrenceNumbers(record) { // Remove gaps
  /* eslint-disable */
  let currentInt = 1;
  let oldtoNewCache = {};

Severity: Minor
Found in src/reindexSubfield6OccurenceNumbers.js - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

function newGetAllLinkedFields(field, record, useSixes = true, useEights = true) {
  removeLinkNotes(record); // should be clear, but let's play safe

  /* eslint-disable */
  field.linkNote = LINK_ROOT;
Severity: Minor
Found in src/removeDuplicateDataFields.js - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

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

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

function subfieldToNormalizedString(sf, tag, targetLinkingNumber = 0, normalizeOccurrenceNumber = false, normalizeEntryTagBoolean = false) {
  // targetLinkingNumber refers to $8.
  // normalizeEntryTagBoolean refers to 1XX/7XX tag values in subfield $6 value.
  if (isValidSubfield6(sf)) { // && targetLinkingNumber === 0) {
    // 1XX/7XX (entry tag) normalization:
Severity: Minor
Found in src/subfield6Utils.js - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

function fieldHandleDuplicateDatafields(field, record) {
  const chain = fieldToChain(field, record);
  nvdebug(` TRY TO HANDLE DUPLICATES OF '${fieldsToString(chain)}'`);

  if (chain.length === 0) {
Severity: Minor
Found in src/removeDuplicateDataFields.js - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

        const fieldModified = {
          tag: '245',
          ind1: ' ',
          ind2: ' ',
          subfields: [
Severity: Major
Found in src/unicode-decomposition.spec.js and 2 other locations - About 55 mins to fix
src/urn.spec.js on lines 17..25
src/urn.spec.js on lines 60..68

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

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

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

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

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

Refactorings

Further Reading

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

  const f337nonElectronic = {
    tag: '337',
    ind1: ' ',
    ind2: ' ',
    subfields: [
Severity: Major
Found in src/urn.spec.js and 2 other locations - About 55 mins to fix
src/unicode-decomposition.spec.js on lines 86..100
src/urn.spec.js on lines 60..68

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

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

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

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

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

Refactorings

Further Reading

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

  const ldf856partial = {
    tag: '856',
    ind1: '4',
    ind2: '0',
    subfields: [
Severity: Major
Found in src/urn.spec.js and 2 other locations - About 55 mins to fix
src/unicode-decomposition.spec.js on lines 86..100
src/urn.spec.js on lines 17..25

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

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 deeply nested control flow statements.
Open

        if (res.special.ifInd2 && res.special.ifInd2.includes(field.ind2)) { // eslint-disable-line functional/no-conditional-statements
          normalPuncRules(lastSubField, res.special.ifBoth, tag, true, res.special.ifLastCharNot);

          // Matches execption to special rule, noPuncIfInd2 (likely with value 4, that indicates copyright mark)
        } else if (res.special.noPuncIfInd2 && field.ind2 && res.special.noPuncIfInd2.includes(field.ind2)) { // eslint-disable-line functional/no-conditional-statements
Severity: Major
Found in src/ending-punctuation.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

        } else if (res.special.termField) {
          lastSubField = findLastSubfield(field);
    
          if (lastSubField) {
            const languageField = field.subfields.find(({code}) => code === res.special.termField);
    Severity: Major
    Found in src/ending-punctuation.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              if (isNaN(subField.code) && res.special.secondLastIfLast !== subField.code) { // eslint-disable-line functional/no-conditional-statements
                lastSubField = subField;
              } // Not control field
      Severity: Major
      Found in src/ending-punctuation.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (typeof res.special.last !== 'undefined' && res.special.secondLastIfLast === subField.code) { // eslint-disable-line functional/no-conditional-statements
                  normalPuncRules(subField, res.special.last, tag, true, false);
                } // Strict because this field should not be abbreviation
        Severity: Major
        Found in src/ending-punctuation.js - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language