NatLibFi/marc-record-validators-melinda

View on GitHub

Showing 1,137 of 1,137 total issues

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

      const recordValidInd2v1Short = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '264',
Severity: Major
Found in src/ending-punctuation.spec.js and 11 other locations - About 2 hrs to fix
src/ending-punctuation.spec.js on lines 524..538
src/ending-punctuation.spec.js on lines 695..709
src/ending-punctuation.spec.js on lines 735..749
src/ending-punctuation.spec.js on lines 751..765
src/ending-punctuation.spec.js on lines 1254..1268
src/ending-punctuation.spec.js on lines 1560..1574
src/ending-punctuation.spec.js on lines 1689..1703
src/ending-punctuation.spec.js on lines 1892..1906
src/ending-punctuation.spec.js on lines 1952..1966
src/ending-punctuation.spec.js on lines 2062..2076
src/ending-punctuation.spec.js on lines 2122..2136

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

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

      const recordInvalidInd2v1 = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '264',
Severity: Major
Found in src/ending-punctuation.spec.js and 11 other locations - About 2 hrs to fix
src/ending-punctuation.spec.js on lines 524..538
src/ending-punctuation.spec.js on lines 664..678
src/ending-punctuation.spec.js on lines 695..709
src/ending-punctuation.spec.js on lines 751..765
src/ending-punctuation.spec.js on lines 1254..1268
src/ending-punctuation.spec.js on lines 1560..1574
src/ending-punctuation.spec.js on lines 1689..1703
src/ending-punctuation.spec.js on lines 1892..1906
src/ending-punctuation.spec.js on lines 1952..1966
src/ending-punctuation.spec.js on lines 2062..2076
src/ending-punctuation.spec.js on lines 2122..2136

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

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

      const recordInvalid658EngNo = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '658',
Severity: Major
Found in src/ending-punctuation.spec.js and 11 other locations - About 2 hrs to fix
src/ending-punctuation.spec.js on lines 524..538
src/ending-punctuation.spec.js on lines 664..678
src/ending-punctuation.spec.js on lines 695..709
src/ending-punctuation.spec.js on lines 735..749
src/ending-punctuation.spec.js on lines 751..765
src/ending-punctuation.spec.js on lines 1254..1268
src/ending-punctuation.spec.js on lines 1560..1574
src/ending-punctuation.spec.js on lines 1689..1703
src/ending-punctuation.spec.js on lines 1892..1906
src/ending-punctuation.spec.js on lines 1952..1966
src/ending-punctuation.spec.js on lines 2062..2076

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

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

      const recordValidCopyright = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '264',
Severity: Major
Found in src/ending-punctuation.spec.js and 11 other locations - About 2 hrs to fix
src/ending-punctuation.spec.js on lines 524..538
src/ending-punctuation.spec.js on lines 664..678
src/ending-punctuation.spec.js on lines 735..749
src/ending-punctuation.spec.js on lines 751..765
src/ending-punctuation.spec.js on lines 1254..1268
src/ending-punctuation.spec.js on lines 1560..1574
src/ending-punctuation.spec.js on lines 1689..1703
src/ending-punctuation.spec.js on lines 1892..1906
src/ending-punctuation.spec.js on lines 1952..1966
src/ending-punctuation.spec.js on lines 2062..2076
src/ending-punctuation.spec.js on lines 2122..2136

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

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

      const recordValidPuncU = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '538',
Severity: Major
Found in src/ending-punctuation.spec.js and 11 other locations - About 2 hrs to fix
src/ending-punctuation.spec.js on lines 524..538
src/ending-punctuation.spec.js on lines 664..678
src/ending-punctuation.spec.js on lines 695..709
src/ending-punctuation.spec.js on lines 735..749
src/ending-punctuation.spec.js on lines 751..765
src/ending-punctuation.spec.js on lines 1560..1574
src/ending-punctuation.spec.js on lines 1689..1703
src/ending-punctuation.spec.js on lines 1892..1906
src/ending-punctuation.spec.js on lines 1952..1966
src/ending-punctuation.spec.js on lines 2062..2076
src/ending-punctuation.spec.js on lines 2122..2136

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

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

      const recordInvalid655EngNo = new MarcRecord({
        leader: '',
        fields: [
          {
            tag: '655',
Severity: Major
Found in src/ending-punctuation.spec.js and 11 other locations - About 2 hrs to fix
src/ending-punctuation.spec.js on lines 524..538
src/ending-punctuation.spec.js on lines 664..678
src/ending-punctuation.spec.js on lines 695..709
src/ending-punctuation.spec.js on lines 735..749
src/ending-punctuation.spec.js on lines 751..765
src/ending-punctuation.spec.js on lines 1254..1268
src/ending-punctuation.spec.js on lines 1560..1574
src/ending-punctuation.spec.js on lines 1689..1703
src/ending-punctuation.spec.js on lines 1892..1906
src/ending-punctuation.spec.js on lines 1952..1966
src/ending-punctuation.spec.js on lines 2122..2136

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

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

export default function () {
  return {
    description: 'Handles empty fields',
    validate,
    fix
Severity: Major
Found in src/empty-fields.js - About 2 hrs to fix

    File sort-tags.spec.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {expect} from 'chai';
    import {MarcRecord} from '@natlibfi/marc-record';
    import validatorFactory from '../src/sort-tags';
    
    describe('sort-tags', () => {
    Severity: Minor
    Found in src/sort-tags.spec.js - About 2 hrs to fix

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

      export default function (config) {
        if (!Array.isArray(config)) {
          throw new TypeError('Configuration array not provided');
        }
      
      
      Severity: Minor
      Found in src/field-exclusion.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 default has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function () {
        return {
          description, fix, validate
        };
      
      
      Severity: Minor
      Found in src/cyrillux-usemarcon-replacement.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 finnishTranslationsAndMappings has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function finnishTranslationsAndMappings(value) {
        return value.replace('analog', 'analoginen').
          replace('approximately', 'noin').
          replace('audio discs', 'äänilevyä').
          replace('black and white', 'mustavalkoinen').
      Severity: Major
      Found in src/cyrillux-usemarcon-replacement.js - About 2 hrs to fix

        Function fix has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function fix(record) {
            // If printed do nothing
        
            // If material is electronic add theis if missing
            if (!hasTag(record, '506', sf506) && !hasTag(record, '506', sf506old)) { // eslint-disable-line functional/no-conditional-statements
        Severity: Major
        Found in src/access-rights.js - About 2 hrs to fix

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

          export default function () {
          
            return {
              description, validate, fix
            };
          Severity: Major
          Found in src/addMissingField041.js - About 2 hrs to fix

            Function fixField020Subfield has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function fixField020Subfield(field, subfield) {
                  split020A(); // subfield and field are in the scope
                  addHyphens(subfield);
                  handleInvalidIsbn(field, subfield); // remove 020$a, add 020$z, Do this last, as it uses deletion
                  return;
            Severity: Major
            Found in src/isbn-issn.js - About 2 hrs to fix

              Function sortByIndexTerms has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function sortByIndexTerms(fieldA, fieldB) { // eslint-disable-line complexity, max-statements
              
                const indexTermFields = ['600', '610', '611', '630', '648', '650', '651', '652', '653', '654', '655', '656', '657', '658', '659', '662'];
              
                function scoreInd2(val) {
              Severity: Major
              Found in src/sortFields.js - About 2 hrs to fix

                Function checkLanguage has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async function checkLanguage(record) {
                    const text = getText(record);
                    const langCode = getLanguageCode(record);
                
                    const Identifier = cldFactory.create();
                Severity: Major
                Found in src/item-language.js - About 2 hrs to fix

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

                      {
                        'tag': '522',
                        'repeatable': true,
                        'fieldType': 'dataField',
                        'indicators': {'ind1': [' ', '8'], 'ind2': ' '},
                  Severity: Major
                  Found in src/melindaCustomMergeFields.js and 2 other locations - About 2 hrs to fix
                  src/melindaCustomMergeFields.js on lines 2172..2182
                  src/melindaCustomMergeFields.js on lines 2231..2241

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

                  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

                      subfields: [
                        {code: 'a', value: 'Aineisto on käytettävissä tutkimus- ja muihin tarkoituksiin;'},
                        {code: 'b', value: 'Kansalliskirjasto;'},
                        {code: 'c', value: 'Laki kulttuuriaineistojen tallettamisesta ja säilyttämisestä'},
                        {code: 'u', value: 'http://www.finlex.fi/fi/laki/ajantasa/2007/20071433'},
                  Severity: Major
                  Found in src/access-rights.spec.js and 1 other location - About 2 hrs to fix
                  src/access-rights.js on lines 48..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 78.

                  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

                          subfields: [
                            {
                              code: 'a',
                              value: 'Aineisto on käytettävissä tutkimus- ja muihin tarkoituksiin;'
                            }, {
                  Severity: Major
                  Found in src/access-rights.js and 1 other location - About 2 hrs to fix
                  src/access-rights.spec.js on lines 59..66

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

                  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

                      {
                        'tag': '516',
                        'repeatable': true,
                        'fieldType': 'dataField',
                        'indicators': {'ind1': [' ', '8'], 'ind2': ' '},
                  Severity: Major
                  Found in src/melindaCustomMergeFields.js and 2 other locations - About 2 hrs to fix
                  src/melindaCustomMergeFields.js on lines 2172..2182
                  src/melindaCustomMergeFields.js on lines 2290..2300

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

                  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