api/src/__tests__/integrationMutations.test.ts

Summary

Maintainability
F
3 days
Test Coverage

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

import * as faker from 'faker';
import { IntegrationsAPI } from '../data/dataSources';
import { graphqlRequest } from '../db/connection';
import {
  brandFactory,
Severity: Major
Found in api/src/__tests__/integrationMutations.test.ts - About 2 days to fix

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

      afterEach(async () => {
        // Clearing test data
        await Users.deleteMany({});
        await Brands.deleteMany({});
        await Customers.deleteMany({});
    Severity: Major
    Found in api/src/__tests__/integrationMutations.test.ts and 9 other locations - About 2 hrs to fix
    api/src/__tests__/boardMutations.test.ts on lines 75..82
    api/src/__tests__/engageMessageQueries.test.ts on lines 49..56
    api/src/__tests__/growthHackMutations.test.ts on lines 89..96
    api/src/__tests__/knowledgeBaseMutations.test.ts on lines 65..72
    api/src/__tests__/scriptMutations.test.ts on lines 36..43
    api/src/__tests__/structureMutations.test.ts on lines 32..39
    api/src/__tests__/taskMutations.test.ts on lines 94..101
    api/src/__tests__/ticketMutations.test.ts on lines 87..94
    api/src/__tests__/widgetMutations.test.ts on lines 1141..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 84.

    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 graphqlRequest(mutation, 'integrationsCopyLeadIntegration', {
            _id: integration._id
          });
        } catch (e) {
    Severity: Major
    Found in api/src/__tests__/integrationMutations.test.ts and 1 other location - About 1 hr to fix
    api/src/__tests__/engageMessageMutations.test.ts on lines 663..669

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

    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

        const uiOptions = {
          color: faker.random.word(),
          wallpaper: faker.random.word(),
          logo: faker.random.image()
        };
    Severity: Major
    Found in api/src/__tests__/integrationMutations.test.ts and 5 other locations - About 1 hr to fix
    api/src/__tests__/automationMutation.test.ts on lines 189..193
    api/src/__tests__/httpEndpoints.test.ts on lines 83..87
    api/src/__tests__/integrationDb.test.ts on lines 452..456
    api/src/__tests__/knowledgeBaseMutations.test.ts on lines 32..36
    api/src/__tests__/pipelineLabelMutations.test.ts on lines 40..44

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

    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 graphqlRequest(mutation, 'integrationsRemove', {
            _id: fbPostIntegration._id
          });
        } catch (e) {
    Severity: Major
    Found in api/src/__tests__/integrationMutations.test.ts and 1 other location - About 1 hr to fix
    api/src/__tests__/integrationQueries.test.ts on lines 330..336

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

    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

        try {
          await graphqlRequest(
            mutation,
            'integrationsCreateExternalIntegration',
            args,
    Severity: Major
    Found in api/src/__tests__/integrationMutations.test.ts and 2 other locations - About 55 mins to fix
    api/src/__tests__/boardMutations.test.ts on lines 143..147
    api/src/__tests__/conversationMutations.test.ts on lines 827..836

    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

        try {
          await graphqlRequest(mutation, 'integrationsRemoveAccount', {
            _id: 'accountId'
          });
        } catch (e) {
    Severity: Minor
    Found in api/src/__tests__/integrationMutations.test.ts and 1 other location - About 50 mins to fix
    api/src/__tests__/integrationQueries.test.ts on lines 469..475

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

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

        try {
          await graphqlRequest(mutation, 'integrationsSendSms', args, {
            dataSources
          });
        } catch (e) {
    Severity: Major
    Found in api/src/__tests__/integrationMutations.test.ts and 10 other locations - About 30 mins to fix
    api/src/__tests__/conversationMutations.test.ts on lines 316..322
    api/src/__tests__/conversationMutations.test.ts on lines 327..333
    api/src/__tests__/conversationMutations.test.ts on lines 337..343
    api/src/__tests__/conversationMutations.test.ts on lines 347..353
    api/src/__tests__/conversationMutations.test.ts on lines 357..363
    api/src/__tests__/conversationMutations.test.ts on lines 367..373
    api/src/__tests__/conversationMutations.test.ts on lines 377..383
    api/src/__tests__/conversationMutations.test.ts on lines 387..393
    api/src/__tests__/conversationMutations.test.ts on lines 435..441
    api/src/__tests__/conversationMutations.test.ts on lines 456..462

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

    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