api/src/__tests__/knowledgeBaseMutations.test.ts

Summary

Maintainability
C
1 day
Test Coverage

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

import * as faker from 'faker';
import { graphqlRequest } from '../db/connection';
import {
  Brands,
  KnowledgeBaseArticles,
Severity: Minor
Found in api/src/__tests__/knowledgeBaseMutations.test.ts - About 2 hrs to fix

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

      afterEach(async () => {
        // Clearing test data
        await KnowledgeBaseTopics.deleteMany({});
        await KnowledgeBaseCategories.deleteMany({});
        await KnowledgeBaseArticles.deleteMany({});
    Severity: Major
    Found in api/src/__tests__/knowledgeBaseMutations.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__/integrationMutations.test.ts on lines 76..83
    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

      test('Remove knowledge base category', async () => {
        const _id = _knowledgeBaseCategory._id;
    
        const mutation = `
          mutation knowledgeBaseCategoriesRemove($_id: String!) {
    Severity: Major
    Found in api/src/__tests__/knowledgeBaseMutations.test.ts and 1 other location - About 2 hrs to fix
    api/src/__tests__/knowledgeBaseMutations.test.ts on lines 151..163

    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

      test('Remove knowledge base topic', async () => {
        const _id = _knowledgeBaseTopic._id;
    
        const mutation = `
          mutation knowledgeBaseTopicsRemove($_id: String!) {
    Severity: Major
    Found in api/src/__tests__/knowledgeBaseMutations.test.ts and 1 other location - About 2 hrs to fix
    api/src/__tests__/knowledgeBaseMutations.test.ts on lines 238..250

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

    const categoryArgs = {
      title: faker.random.word(),
      description: faker.random.word(),
      icon: faker.random.word()
    };
    Severity: Major
    Found in api/src/__tests__/knowledgeBaseMutations.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__/integrationMutations.test.ts on lines 159..163
    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

    There are no issues that match your filters.

    Category
    Status