NatLibFi/marc-record-js

View on GitHub

Showing 87 of 87 total issues

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

    it('Should consider the record invalid', () => {
      const record = {
        leader: '02848ccm a22005894i 4500'
      };

Severity: Major
Found in src/utils.spec.js and 1 other location - About 3 hrs to fix
src/utils.spec.js on lines 87..99

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

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

        it('Should consider the field valid (subfield with uppercase code), characters: false', () => {
          const field = {'tag': 'CAT', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'A', 'value': 'foo'}, {'code': 'c', 'value': '20150121'}]};
          // eslint-disable-next-line no-unused-expressions
          expect(Utils.validateField(field, {characters: false})).not.to.throw;
        });
Severity: Major
Found in src/utils.spec.js and 3 other locations - About 3 hrs to fix
src/utils.spec.js on lines 446..450
src/utils.spec.js on lines 500..504
src/utils.spec.js on lines 524..530

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

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

        it('Should consider the field valid (subfield with non-ASCII code), characters: false', () => {
          const field = {'tag': 'CAT', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'Ä', 'value': 'foo'}, {'code': 'c', 'value': '20150121'}]};
          // eslint-disable-next-line no-unused-expressions
          expect(Utils.validateField(field, {characters: false})).not.to.throw;
        });
Severity: Major
Found in src/utils.spec.js and 3 other locations - About 3 hrs to fix
src/utils.spec.js on lines 446..450
src/utils.spec.js on lines 480..484
src/utils.spec.js on lines 524..530

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

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

        it('Should consider the field valid (subfield with empty code), characters: false', () => {
          const field = {'tag': 'CAT', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': ' ', 'value': 'foo'}, {'code': 'c', 'value': '20150121'}]};
          // eslint-disable-next-line no-unused-expressions
          expect(Utils.validateField(field, {characters: false})).not.to.throw;
        });
Severity: Major
Found in src/utils.spec.js and 3 other locations - About 3 hrs to fix
src/utils.spec.js on lines 480..484
src/utils.spec.js on lines 500..504
src/utils.spec.js on lines 524..530

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

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

        it('Should consider the field valid (subfield with empty value), subfieldValues: false', () => {
          const field = {'tag': 'CAT', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'b', 'value': ''}, {'code': 'c', 'value': '20150121'}]};

          // eslint-disable-next-line no-unused-expressions
          expect(Utils.validateField(field, {subfieldValues: false})).not.to.throw;
Severity: Major
Found in src/utils.spec.js and 3 other locations - About 3 hrs to fix
src/utils.spec.js on lines 446..450
src/utils.spec.js on lines 480..484
src/utils.spec.js on lines 500..504

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

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

      it('Should consider the field valid (tag with non-alphanumeric character), characters: false', () => {
        const field = {'tag': '#44', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};
        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
      });
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 286..290
src/utils.spec.js on lines 376..380
src/utils.spec.js on lines 397..401
src/utils.spec.js on lines 624..628
src/utils.spec.js on lines 645..650
src/utils.spec.js on lines 666..670

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

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

      it('Should consider the field valid (uppercase indicator), characters: false', () => {
        const field = {'tag': 'CAT', 'ind1': 'A', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};
        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
      });
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 286..290
src/utils.spec.js on lines 355..359
src/utils.spec.js on lines 376..380
src/utils.spec.js on lines 397..401
src/utils.spec.js on lines 645..650
src/utils.spec.js on lines 666..670

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

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

      it('Should consider the field invalid (non alpha-numeric/blank indicator), characters: false', () => {
        const field = {'tag': 'CAT', 'ind1': '#', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};

        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 286..290
src/utils.spec.js on lines 355..359
src/utils.spec.js on lines 376..380
src/utils.spec.js on lines 397..401
src/utils.spec.js on lines 624..628
src/utils.spec.js on lines 666..670

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

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

      it('Should consider the field valid (datafield tag beginning with 00), characters: false', () => {
        const field = {'tag': '004', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};
        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
      });
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 355..359
src/utils.spec.js on lines 376..380
src/utils.spec.js on lines 397..401
src/utils.spec.js on lines 624..628
src/utils.spec.js on lines 645..650
src/utils.spec.js on lines 666..670

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

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

      it('Should consider the field valid (tag with mixed case characters), characters: false', () => {
        const field = {'tag': 'AaA', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};
        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
      });
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 286..290
src/utils.spec.js on lines 355..359
src/utils.spec.js on lines 397..401
src/utils.spec.js on lines 624..628
src/utils.spec.js on lines 645..650
src/utils.spec.js on lines 666..670

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

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

      it('Should consider the field invalid (non-ASCII indicator), characters: false', () => {
        const field = {'tag': 'CAT', 'ind1': 'Ä', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};
        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
      });
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 286..290
src/utils.spec.js on lines 355..359
src/utils.spec.js on lines 376..380
src/utils.spec.js on lines 397..401
src/utils.spec.js on lines 624..628
src/utils.spec.js on lines 645..650

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

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

      it('Should consider the field valid (tag with non-ASCII characters), characters: false', () => {
        const field = {'tag': 'ÄÄÄ', 'ind1': ' ', 'ind2': ' ', 'subfields': [{'code': 'c', 'value': '20150121'}]};
        // eslint-disable-next-line no-unused-expressions
        expect(Utils.validateField(field, {characters: false})).not.to.throw;
      });
Severity: Major
Found in src/utils.spec.js and 6 other locations - About 2 hrs to fix
src/utils.spec.js on lines 286..290
src/utils.spec.js on lines 355..359
src/utils.spec.js on lines 376..380
src/utils.spec.js on lines 624..628
src/utils.spec.js on lines 645..650
src/utils.spec.js on lines 666..670

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

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

File index.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable functional/no-this-expressions */

import {fieldOrderComparator} from './marcFieldSort';
import {clone, validateRecord, validateField} from './utils';
import MarcRecordError from './error';
Severity: Minor
Found in src/index.js - About 2 hrs to fix

    Function schema has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    function schema({fields = true, subfields = true, subfieldValues = true, controlFieldValues = true, leader = false, characters = false, noControlCharacters = false, noAdditionalProperties = false}) {
      return {
        type: 'object',
        properties: {
          leader: {
    Severity: Minor
    Found in src/schema.js - About 2 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 sortAlphabetically has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    export function sortAlphabetically(fieldA, fieldB) {
      // These are Aleph specific rules. However, we think that they are ok for all Aleph users, and irrelevant for others.
      const tagToSortingSubfields = {
        'LOW': ['a'],
        'SID': ['c']
    Severity: Minor
    Found in src/marcFieldSort.js - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

          it('Should consider the field valid (numeric controlfield tag not beginning with 00), characters: false', () => {
            const field = {'tag': '500', 'value': '123456'};
    
            // eslint-disable-next-line no-unused-expressions
            expect(Utils.validateField(field, {characters: false})).not.to.throw;
    Severity: Major
    Found in src/utils.spec.js and 1 other location - About 1 hr to fix
    src/utils.spec.js on lines 261..265

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

    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

          it('Should consider the field valid (controlfield with non-ASCII content), characters: false', () => {
            const field = {'tag': '003', 'value': 'ÅÖÖ'};
            // eslint-disable-next-line no-unused-expressions
            expect(Utils.validateField(field, {characters: false})).not.to.throw;
          });
    Severity: Major
    Found in src/utils.spec.js and 1 other location - About 1 hr to fix
    src/utils.spec.js on lines 239..244

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

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

    export function sortAlphabetically(fieldA, fieldB) {
      // These are Aleph specific rules. However, we think that they are ok for all Aleph users, and irrelevant for others.
      const tagToSortingSubfields = {
        'LOW': ['a'],
        'SID': ['c']
    Severity: Minor
    Found in src/marcFieldSort.js - About 1 hr to fix

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

          function formatSubfields(field) {
            return field.subfields.map(sf => `${sf.code}${sf.value || ''}`).join('‡');
          }
      Severity: Major
      Found in src/marcFieldSort.js and 1 other location - About 1 hr to fix
      src/index.js on lines 282..284

      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

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

            function formatSubfields(field) {
              return field.subfields.map(sf => `${sf.code}${sf.value || ''}`).join('‡');
            }
      Severity: Major
      Found in src/index.js and 1 other location - About 1 hr to fix
      src/marcFieldSort.js on lines 16..18

      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

      Severity
      Category
      Status
      Source
      Language