integrations/src/helpers.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function removeIntegration has 323 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const removeIntegration = async (
  integrationErxesApiId: string,
  removeAll: boolean = false
): Promise<string> => {
  const integration = await Integrations.findOne({
Severity: Major
Found in integrations/src/helpers.ts - About 1 day to fix

    File helpers.ts has 618 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {
      Conversations as CallProConversations,
      Customers as CallProCustomers
    } from './callpro/models';
    import {
    Severity: Major
    Found in integrations/src/helpers.ts - About 1 day to fix

      Function removeIntegration has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
      Open

      export const removeIntegration = async (
        integrationErxesApiId: string,
        removeAll: boolean = false
      ): Promise<string> => {
        const integration = await Integrations.findOne({
      Severity: Minor
      Found in integrations/src/helpers.ts - About 1 day to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function updateIntegrationConfigs has 108 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const updateIntegrationConfigs = async (configsMap): Promise<void> => {
        const getValueAsString = async name => {
          const entry = await Configs.getConfig(name);
      
          if (entry.value) {
      Severity: Major
      Found in integrations/src/helpers.ts - About 4 hrs to fix

        Function updateIntegrationConfigs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export const updateIntegrationConfigs = async (configsMap): Promise<void> => {
          const getValueAsString = async name => {
            const entry = await Configs.getConfig(name);
        
            if (entry.value) {
        Severity: Minor
        Found in integrations/src/helpers.ts - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function removeAccount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export const removeAccount = async (
          _id: string
        ): Promise<{ erxesApiIds: string | string[] } | Error> => {
          const account = await Accounts.findOne({ _id });
        
        
        Severity: Minor
        Found in integrations/src/helpers.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

          if (kind === 'imap') {
            debugNylas('Removing nylas-imap entries');
        
            const conversationIds = await NylasImapConversations.find(
              selector
        Severity: Major
        Found in integrations/src/helpers.ts and 4 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 318..338
        integrations/src/helpers.ts on lines 340..360
        integrations/src/helpers.ts on lines 362..382
        integrations/src/helpers.ts on lines 384..404

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

        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

          if (kind === 'office365') {
            debugNylas('Removing nylas-office365 entries');
        
            const conversationIds = await NylasOffice365Conversations.find(
              selector
        Severity: Major
        Found in integrations/src/helpers.ts and 4 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 296..316
        integrations/src/helpers.ts on lines 340..360
        integrations/src/helpers.ts on lines 362..382
        integrations/src/helpers.ts on lines 384..404

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

        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

          if (kind === 'exchange') {
            debugNylas('Removing nylas-exchange entries');
        
            const conversationIds = await NylasYahooConversations.find(
              selector
        Severity: Major
        Found in integrations/src/helpers.ts and 4 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 296..316
        integrations/src/helpers.ts on lines 318..338
        integrations/src/helpers.ts on lines 340..360
        integrations/src/helpers.ts on lines 384..404

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

        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

          if (kind === 'yahoo') {
            debugNylas('Removing nylas-yahoo entries');
        
            const conversationIds = await NylasYahooConversations.find(
              selector
        Severity: Major
        Found in integrations/src/helpers.ts and 4 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 296..316
        integrations/src/helpers.ts on lines 318..338
        integrations/src/helpers.ts on lines 340..360
        integrations/src/helpers.ts on lines 362..382

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

        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

          if (kind === 'outlook') {
            debugNylas('Removing nylas-outlook entries');
        
            const conversationIds = await NylasOutlookConversations.find(
              selector
        Severity: Major
        Found in integrations/src/helpers.ts and 4 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 296..316
        integrations/src/helpers.ts on lines 318..338
        integrations/src/helpers.ts on lines 362..382
        integrations/src/helpers.ts on lines 384..404

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

        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

          if (kind === 'viber') {
            debugSmooch('Removing Viber entries');
            const conversationIds = await SmoochViberConversations.find(
              selector
            ).distinct('_id');
        Severity: Major
        Found in integrations/src/helpers.ts and 3 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 420..436
        integrations/src/helpers.ts on lines 457..474
        integrations/src/helpers.ts on lines 476..493

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

        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

          if (kind === 'telegram') {
            debugSmooch('Removing Telegram entries');
            const conversationIds = await SmoochTelegramConversations.find(
              selector
            ).distinct('_id');
        Severity: Major
        Found in integrations/src/helpers.ts and 3 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 438..455
        integrations/src/helpers.ts on lines 457..474
        integrations/src/helpers.ts on lines 476..493

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

        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

          if (kind === 'line') {
            debugSmooch('Removing Line entries');
            const conversationIds = await SmoochLineConversations.find(
              selector
            ).distinct('_id');
        Severity: Major
        Found in integrations/src/helpers.ts and 3 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 420..436
        integrations/src/helpers.ts on lines 438..455
        integrations/src/helpers.ts on lines 476..493

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

        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

          if (kind === 'twilio') {
            debugSmooch('Removing Twilio entries');
            const conversationIds = await SmoochTwilioConversations.find(
              selector
            ).distinct('_id');
        Severity: Major
        Found in integrations/src/helpers.ts and 3 other locations - About 4 hrs to fix
        integrations/src/helpers.ts on lines 420..436
        integrations/src/helpers.ts on lines 438..455
        integrations/src/helpers.ts on lines 457..474

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

        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 getValueAsString = async name => {
            const entry = await Configs.getConfig(name);
        
            if (entry.value) {
              return entry.value.toString();
        Severity: Major
        Found in integrations/src/helpers.ts and 1 other location - About 1 hr to fix
        engages-email-sender/src/utils.ts on lines 134..142

        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

              prevTwitterConfig.oauth.consumer_key !==
                updatedTwitterConfig.oauth.consumer_key ||
              prevTwitterConfig.oauth.consumer_secret !==
                updatedTwitterConfig.oauth.consumer_secret
        Severity: Minor
        Found in integrations/src/helpers.ts and 1 other location - About 30 mins to fix
        integrations/src/helpers.ts on lines 689..691

        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

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

              prevTwitterConfig.oauth.token !== updatedTwitterConfig.oauth.token ||
              prevTwitterConfig.oauth.token_secret !==
                prevTwitterConfig.oauth.token_secret ||
        Severity: Minor
        Found in integrations/src/helpers.ts and 1 other location - About 30 mins to fix
        integrations/src/helpers.ts on lines 681..684

        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