NatLibFi/marc-record-validators-melinda

View on GitHub
src/field-structure.spec.js

Summary

Maintainability
F
1 wk
Test Coverage

File field-structure.spec.js has 550 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {MarcRecord} from '@natlibfi/marc-record';
import validatorFactory from '../src/field-structure';

Severity: Major
Found in src/field-structure.spec.js - About 1 day to fix

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

        it('Find the record valid (Dependency on leader)', async () => {
          const validator = await validatorFactory([{tag: /^007$/u, dependencies: [{leader: /^.{6}[at]/u}]}]);
          const result = await validator.validate(new MarcRecord({
            leader: '00000ccm^a22003372i^4500',
            fields: [
    Severity: Major
    Found in src/field-structure.spec.js and 1 other location - About 4 hrs to fix
    src/field-structure.spec.js on lines 595..606

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

    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 recordInvalidTooMany = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 2 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 181..215
    src/field-structure.spec.js on lines 281..315

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

    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 recordInvalidMany = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 2 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 281..315
    src/field-structure.spec.js on lines 317..351

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

    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('Find the record invalid (Dependency on leader)', async () => {
          const validator = await validatorFactory([{tag: /^007$/u, dependencies: [{leader: /^.{6}[at]/u}]}]);
          const result = await validator.validate(new MarcRecord({
            leader: '00000cam^a22003372i^4500',
            fields: [
    Severity: Major
    Found in src/field-structure.spec.js and 1 other location - About 4 hrs to fix
    src/field-structure.spec.js on lines 582..593

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

    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 recordInvalidExtra = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 2 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 181..215
    src/field-structure.spec.js on lines 317..351

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

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

        const recordInvalid = new MarcRecord({
          leader: '63ab75afoo122myhgh',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 4 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 148..179
    src/field-structure.spec.js on lines 248..279
    src/field-structure.spec.js on lines 353..384
    src/field-structure.spec.js on lines 502..533

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

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

        const recordValid = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 4 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 148..179
    src/field-structure.spec.js on lines 353..384
    src/field-structure.spec.js on lines 502..533
    src/field-structure.spec.js on lines 535..566

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

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

        const recordValid = new MarcRecord({
          leader: '63ab75sfoo122myhgh',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 4 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 148..179
    src/field-structure.spec.js on lines 248..279
    src/field-structure.spec.js on lines 353..384
    src/field-structure.spec.js on lines 535..566

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

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

        const recordInvalidRegExp = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 4 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 148..179
    src/field-structure.spec.js on lines 248..279
    src/field-structure.spec.js on lines 502..533
    src/field-structure.spec.js on lines 535..566

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

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

        const recordValid = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '001',
    Severity: Major
    Found in src/field-structure.spec.js and 4 other locations - About 4 hrs to fix
    src/field-structure.spec.js on lines 248..279
    src/field-structure.spec.js on lines 353..384
    src/field-structure.spec.js on lines 502..533
    src/field-structure.spec.js on lines 535..566

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

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

        const recordInvalidMissing = new MarcRecord({
          leader: '',
          fields: [
            {
              tag: '100',
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 3 hrs to fix
    src/field-exclusion.spec.js on lines 226..244
    src/field-exclusion.spec.js on lines 337..355
    src/field-exclusion.spec.js on lines 444..462
    src/field-exclusion.spec.js on lines 545..563
    src/field-exclusion.spec.js on lines 565..583
    src/field-exclusion.spec.js on lines 625..643
    src/field-exclusion.spec.js on lines 645..663
    src/field-exclusion.spec.js on lines 783..801
    src/subfield-exclusion.spec.js on lines 459..477

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

        it('Throws an error when config array has excluded element', () => {
          const config = [
            {
              leader: /^035$/u,
              tag: /^035$/u
    Severity: Major
    Found in src/field-structure.spec.js and 1 other location - About 2 hrs to fix
    src/field-structure.spec.js on lines 44..57

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

    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('Throws an error when config array has unidentified field', () => {
          const config = [
            {
              leader: /^035$/u,
              tags: /^035$/u
    Severity: Major
    Found in src/field-structure.spec.js and 1 other location - About 2 hrs to fix
    src/field-structure.spec.js on lines 74..87

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

    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

        it('Throws an error when config array not provided', () => {
          try {
            validatorFactory();
          } catch (error) {
            expect(error).to.be.an('error').with.property('message', 'Configuration array not provided');
    Severity: Major
    Found in src/field-structure.spec.js and 2 other locations - About 1 hr to fix
    src/fields-present.spec.js on lines 21..27
    src/fixed-fields.spec.js on lines 21..27

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

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

        it('Finds the record invalid: Too many occurances', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalidTooMany);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record invalid: Missing subfield', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalidMissingSubfield);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record invalid: Missing field', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalidMissing);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record invalid', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalid);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573

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

        it('Finds the record valid', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordValid);
    
          expect(result).to.eql({valid: true});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record valid', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordValid);
    
          expect(result).to.eql({valid: true});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record invalid: Extra field in strict', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalidExtra);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record invalid: Invalid RegExp', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalidRegExp);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record valid', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordValid);
    
          expect(result).to.eql({valid: true});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 224..229
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 575..580

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

        it('Finds the record invalid: Too many subfields', async () => {
          const validator = await validatorFactory(config);
          const result = await validator.validate(recordInvalidMany);
    
          expect(result).to.eql({valid: false});
    Severity: Major
    Found in src/field-structure.spec.js and 9 other locations - About 1 hr to fix
    src/field-structure.spec.js on lines 217..222
    src/field-structure.spec.js on lines 446..451
    src/field-structure.spec.js on lines 453..458
    src/field-structure.spec.js on lines 460..465
    src/field-structure.spec.js on lines 467..472
    src/field-structure.spec.js on lines 474..479
    src/field-structure.spec.js on lines 480..485
    src/field-structure.spec.js on lines 568..573
    src/field-structure.spec.js on lines 575..580

    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

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

        const config = [
          {
            tag: /^035$/u,
            ind1: /^0$/u,
            ind2: /^1$/u
    Severity: Minor
    Found in src/field-structure.spec.js and 1 other location - About 40 mins to fix
    src/field-structure.spec.js on lines 12..23

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

    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

        const config = [
          {
            tag: /^035$/u,
            ind1: /^0$/u,
            ind2: /^1$/u
    Severity: Minor
    Found in src/field-structure.spec.js and 1 other location - About 40 mins to fix
    src/field-structure.spec.js on lines 135..146

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

    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

    There are no issues that match your filters.

    Category
    Status