api/src/__tests__/engageMessageDb.test.ts

Summary

Maintainability
F
1 wk
Test Coverage

File engageMessageDb.test.ts has 1023 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as faker from 'faker';
import * as sinon from 'sinon';
import { MESSAGE_KINDS } from '../data/constants';
import * as utils from '../data/utils';
import {
Severity: Major
Found in api/src/__tests__/engageMessageDb.test.ts - About 2 days to fix

    Function elkMock has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const elkMock = sinon.stub(elk, 'fetchElk').callsFake(() => {
          return Promise.resolve({
            hits: {
              hits: [
                {
    Severity: Minor
    Found in api/src/__tests__/engageMessageDb.test.ts - About 1 hr to fix

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

        test('Get engage message', async () => {
          try {
            await EngageMessages.getEngageMessage('fakeId');
          } catch (e) {
            expect(e.message).toBe('Campaign not found');
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 17 other locations - About 2 hrs to fix
      api/src/__tests__/boardDb.test.ts on lines 479..489
      api/src/__tests__/checklistDb.test.ts on lines 58..68
      api/src/__tests__/checklistDb.test.ts on lines 70..80
      api/src/__tests__/companyDb.test.ts on lines 66..76
      api/src/__tests__/conversationDb.test.ts on lines 44..56
      api/src/__tests__/conversationDb.test.ts on lines 58..68
      api/src/__tests__/customerDb.test.ts on lines 47..57
      api/src/__tests__/dashboardDb.test.ts on lines 22..32
      api/src/__tests__/dealDb.test.ts on lines 59..69
      api/src/__tests__/emailTemplateDb.test.ts on lines 19..29
      api/src/__tests__/internalNoteDb.test.ts on lines 47..57
      api/src/__tests__/responseTemplateDb.test.ts on lines 19..31
      api/src/__tests__/segmentDb.test.ts on lines 69..79
      api/src/__tests__/tagDb.test.ts on lines 29..39
      api/src/__tests__/ticketDb.test.ts on lines 44..54
      api/src/__tests__/userDb.test.ts on lines 26..36
      api/src/__tests__/webhookDb.test.ts on lines 22..32

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

      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

          try {
            await EngageMessages.updateEngageMessage(manualMessage._id, {
              title: 'Message test updated',
              method: manualMessage.method,
              kind: manualMessage.kind
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/webhookDb.test.ts on lines 57..67

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

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

        afterEach(async () => {
          // Clearing test data
          await Customers.deleteMany({});
          await Integrations.deleteMany({});
          await Conversations.deleteMany({});
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 13 other locations - About 1 hr to fix
      api/src/__tests__/boardDb.test.ts on lines 52..58
      api/src/__tests__/calendarDb.test.ts on lines 25..31
      api/src/__tests__/calendarMutations.test.ts on lines 32..38
      api/src/__tests__/calendarQueries.test.ts on lines 33..39
      api/src/__tests__/customerMutations.test.ts on lines 108..114
      api/src/__tests__/dealDb.test.ts on lines 51..57
      api/src/__tests__/dealQueries.test.ts on lines 148..154
      api/src/__tests__/growthHackDb.test.ts on lines 36..42
      api/src/__tests__/integrationQueries.test.ts on lines 68..74
      api/src/__tests__/taskDb.test.ts on lines 36..42
      api/src/__tests__/ticketDb.test.ts on lines 36..42
      api/src/__tests__/widgetMutations.test.ts on lines 72..78
      api/src/__tests__/widgetQueries.test.ts on lines 33..39

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

      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

        test('remove a message', async () => {
          await EngageMessages.removeEngageMessage(_message._id);
      
          const messagesCounts = await EngageMessages.find({}).countDocuments();
      
      
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/channelDb.test.ts on lines 175..181

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

      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

          await engageMessageFactory({
            kind: MESSAGE_KINDS.VISITOR_AUTO,
            userId: _user._id,
            isLive: true,
            customerIds: [_visitor.id],
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 1173..1182

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

      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

          await engageMessageFactory({
            kind: MESSAGE_KINDS.MANUAL,
            userId: _user._id,
            isLive: true,
            customerIds: [_customer.id],
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 1162..1171

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

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

          test('isNot: matching', () => {
            const response = EngageMessages.checkRule({
              rule: isNotRule,
              browserInfo: { url: '/category' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 5 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 794..801
      api/src/__tests__/engageMessageDb.test.ts on lines 867..874
      api/src/__tests__/engageMessageDb.test.ts on lines 892..899
      api/src/__tests__/engageMessageDb.test.ts on lines 917..924
      api/src/__tests__/engageMessageDb.test.ts on lines 996..1003

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

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

          test('endsWith: matching', () => {
            const response = EngageMessages.checkRule({
              rule: endsWithRule,
              browserInfo: { language: 'mongolian' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 5 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 794..801
      api/src/__tests__/engageMessageDb.test.ts on lines 819..826
      api/src/__tests__/engageMessageDb.test.ts on lines 867..874
      api/src/__tests__/engageMessageDb.test.ts on lines 892..899
      api/src/__tests__/engageMessageDb.test.ts on lines 996..1003

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

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

          test('contains: matching', () => {
            const response = EngageMessages.checkRule({
              rule: containsRule,
              browserInfo: { url: '/page' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 5 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 794..801
      api/src/__tests__/engageMessageDb.test.ts on lines 819..826
      api/src/__tests__/engageMessageDb.test.ts on lines 867..874
      api/src/__tests__/engageMessageDb.test.ts on lines 892..899
      api/src/__tests__/engageMessageDb.test.ts on lines 917..924

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

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

          test('is: matching', () => {
            const response = EngageMessages.checkRule({
              rule: browserLanguageRule,
              browserInfo: { language: 'en' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 5 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 819..826
      api/src/__tests__/engageMessageDb.test.ts on lines 867..874
      api/src/__tests__/engageMessageDb.test.ts on lines 892..899
      api/src/__tests__/engageMessageDb.test.ts on lines 917..924
      api/src/__tests__/engageMessageDb.test.ts on lines 996..1003

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

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

          test('hasAnyValue: matching', () => {
            const response = EngageMessages.checkRule({
              rule: hasAnyValueRule,
              browserInfo: { countryCode: 'MN' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 5 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 794..801
      api/src/__tests__/engageMessageDb.test.ts on lines 819..826
      api/src/__tests__/engageMessageDb.test.ts on lines 892..899
      api/src/__tests__/engageMessageDb.test.ts on lines 917..924
      api/src/__tests__/engageMessageDb.test.ts on lines 996..1003

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

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

          test('startsWith: matching', () => {
            const response = EngageMessages.checkRule({
              rule: startsWithRule,
              browserInfo: { language: 'english' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 5 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 794..801
      api/src/__tests__/engageMessageDb.test.ts on lines 819..826
      api/src/__tests__/engageMessageDb.test.ts on lines 867..874
      api/src/__tests__/engageMessageDb.test.ts on lines 917..924
      api/src/__tests__/engageMessageDb.test.ts on lines 996..1003

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

      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

          test('greaterThan: matching', () => {
            const response = EngageMessages.checkRule({
              rule: greaterThanRule,
              browserInfo: {},
              numberOfVisits: 2
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 970..978

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

      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

          test('lessThan: matching', () => {
            const response = EngageMessages.checkRule({
              rule: lessThanRule,
              browserInfo: {},
              numberOfVisits: 0
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 943..951

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

      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

          test('does not contains: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: doesNotContainsRule,
              browserInfo: { url: '/page' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 810..817
      api/src/__tests__/engageMessageDb.test.ts on lines 834..841
      api/src/__tests__/engageMessageDb.test.ts on lines 883..890
      api/src/__tests__/engageMessageDb.test.ts on lines 908..915
      api/src/__tests__/engageMessageDb.test.ts on lines 987..994
      api/src/__tests__/engageMessageDb.test.ts on lines 1021..1028

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('isNot: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: isNotRule,
              browserInfo: { url: '/page' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 834..841
      api/src/__tests__/engageMessageDb.test.ts on lines 883..890
      api/src/__tests__/engageMessageDb.test.ts on lines 908..915
      api/src/__tests__/engageMessageDb.test.ts on lines 987..994
      api/src/__tests__/engageMessageDb.test.ts on lines 1012..1019
      api/src/__tests__/engageMessageDb.test.ts on lines 1021..1028

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('isUnknown: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: isUnknownRule,
              browserInfo: { city: 'Ulaanbaatar' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 810..817
      api/src/__tests__/engageMessageDb.test.ts on lines 883..890
      api/src/__tests__/engageMessageDb.test.ts on lines 908..915
      api/src/__tests__/engageMessageDb.test.ts on lines 987..994
      api/src/__tests__/engageMessageDb.test.ts on lines 1012..1019
      api/src/__tests__/engageMessageDb.test.ts on lines 1021..1028

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('contains: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: containsRule,
              browserInfo: { url: '/test' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 810..817
      api/src/__tests__/engageMessageDb.test.ts on lines 834..841
      api/src/__tests__/engageMessageDb.test.ts on lines 883..890
      api/src/__tests__/engageMessageDb.test.ts on lines 908..915
      api/src/__tests__/engageMessageDb.test.ts on lines 1012..1019
      api/src/__tests__/engageMessageDb.test.ts on lines 1021..1028

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('endsWith: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: endsWithRule,
              browserInfo: { language: 'english' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 810..817
      api/src/__tests__/engageMessageDb.test.ts on lines 834..841
      api/src/__tests__/engageMessageDb.test.ts on lines 883..890
      api/src/__tests__/engageMessageDb.test.ts on lines 987..994
      api/src/__tests__/engageMessageDb.test.ts on lines 1012..1019
      api/src/__tests__/engageMessageDb.test.ts on lines 1021..1028

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('startsWith: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: startsWithRule,
              browserInfo: { language: 'mongolian' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 810..817
      api/src/__tests__/engageMessageDb.test.ts on lines 834..841
      api/src/__tests__/engageMessageDb.test.ts on lines 908..915
      api/src/__tests__/engageMessageDb.test.ts on lines 987..994
      api/src/__tests__/engageMessageDb.test.ts on lines 1012..1019
      api/src/__tests__/engageMessageDb.test.ts on lines 1021..1028

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('does not contains: matching', () => {
            const response = EngageMessages.checkRule({
              rule: doesNotContainsRule,
              browserInfo: { url: '/test' }
            });
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 6 other locations - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 810..817
      api/src/__tests__/engageMessageDb.test.ts on lines 834..841
      api/src/__tests__/engageMessageDb.test.ts on lines 883..890
      api/src/__tests__/engageMessageDb.test.ts on lines 908..915
      api/src/__tests__/engageMessageDb.test.ts on lines 987..994
      api/src/__tests__/engageMessageDb.test.ts on lines 1012..1019

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

            messenger: {
              brandId: _brand._id,
              rules: [
                {
                  kind: 'currentPageUrl',
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 483..498

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

            messenger: {
              brandId: _brand._id,
              rules: [
                {
                  kind: 'currentPageUrl',
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 1133..1148

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          await engageMessageFactory({
            kind: 'manual',
            userId: _user._id,
            isLive: true,
            customerIds: [_customer.id],
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 512..521

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('greaterThan: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: greaterThanRule,
              browserInfo: {},
              numberOfVisits: 0
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 960..968

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          await engageMessageFactory({
            kind: 'visitorAuto',
            userId: _user._id,
            isLive: true,
            customerIds: [_visitor.id],
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 523..532

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('lessThan: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: lessThanRule,
              browserInfo: {},
              numberOfVisits: 2
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 1 hr to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 933..941

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 60.

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

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

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

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

      Refactorings

      Further Reading

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

          test('hasAnyValue: not matching', () => {
            const response = EngageMessages.checkRule({
              rule: hasAnyValueRule,
              browserInfo: {}
            });
      Severity: Minor
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 55 mins to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 843..850

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 54.

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

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

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

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

      Refactorings

      Further Reading

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

          test('isUnknown: matching', () => {
            const response = EngageMessages.checkRule({
              rule: isUnknownRule,
              browserInfo: {}
            });
      Severity: Minor
      Found in api/src/__tests__/engageMessageDb.test.ts and 1 other location - About 55 mins to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 858..865

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 54.

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

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

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

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

      Refactorings

      Further Reading

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

          await EngageMessages.createVisitorOrCustomerMessages({
            brandId: _brand._id,
            customer: customer2,
            integrationId: _integration._id,
            browserInfo: {
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 3 other locations - About 40 mins to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 666..673
      api/src/__tests__/engageMessageDb.test.ts on lines 724..731
      api/src/__tests__/engageMessageDb.test.ts on lines 1232..1239

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

      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

          await EngageMessages.createVisitorOrCustomerMessages({
            brandId: _brand._id,
            customer,
            integrationId: _integration._id,
            browserInfo: {
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 3 other locations - About 40 mins to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 657..664
      api/src/__tests__/engageMessageDb.test.ts on lines 666..673
      api/src/__tests__/engageMessageDb.test.ts on lines 724..731

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

      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

          await EngageMessages.createVisitorOrCustomerMessages({
            brandId: _brand._id,
            customer,
            integrationId: _integration._id,
            browserInfo: {
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 3 other locations - About 40 mins to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 657..664
      api/src/__tests__/engageMessageDb.test.ts on lines 666..673
      api/src/__tests__/engageMessageDb.test.ts on lines 1232..1239

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

      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

          await EngageMessages.createVisitorOrCustomerMessages({
            brandId: _brand._id,
            customer: customer1,
            integrationId: _integration._id,
            browserInfo: {
      Severity: Major
      Found in api/src/__tests__/engageMessageDb.test.ts and 3 other locations - About 40 mins to fix
      api/src/__tests__/engageMessageDb.test.ts on lines 657..664
      api/src/__tests__/engageMessageDb.test.ts on lines 724..731
      api/src/__tests__/engageMessageDb.test.ts on lines 1232..1239

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

      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