api/src/data/resolvers/mutations/conversations.ts

Summary

Maintainability
F
4 days
Test Coverage

File conversations.ts has 743 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as strip from 'strip';
import * as _ from 'underscore';
import {
  Configs,
  Conformities,
Severity: Major
Found in api/src/data/resolvers/mutations/conversations.ts - About 1 day to fix

    Function conversationMessageAdd has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async conversationMessageAdd(
        _root,
        doc: IConversationMessageAdd,
        { user, dataSources }: IContext
      ) {
    Severity: Major
    Found in api/src/data/resolvers/mutations/conversations.ts - About 4 hrs to fix

      Function conversationConvertToCard has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async conversationConvertToCard(
          _root,
          params: IConversationConvert,
          { user, docModifier }: IContext
        ) {
      Severity: Major
      Found in api/src/data/resolvers/mutations/conversations.ts - About 2 hrs to fix

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

          async conversationMessageAdd(
            _root,
            doc: IConversationMessageAdd,
            { user, dataSources }: IContext
          ) {
        Severity: Minor
        Found in api/src/data/resolvers/mutations/conversations.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 sendConversationToIntegrations has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const sendConversationToIntegrations = async (
          type: string,
          integrationId: string,
          conversationId: string,
          requestName: string,
        Severity: Minor
        Found in api/src/data/resolvers/mutations/conversations.ts - About 1 hr to fix

          Function sendNotifications has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          const sendNotifications = async ({
            user,
            conversations,
            type,
            mobile,
          Severity: Minor
          Found in api/src/data/resolvers/mutations/conversations.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 conversationConvertToCard has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            async conversationConvertToCard(
              _root,
              params: IConversationConvert,
              { user, docModifier }: IContext
            ) {
          Severity: Minor
          Found in api/src/data/resolvers/mutations/conversations.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 conversationsReplyFacebookComment has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async conversationsReplyFacebookComment(
              _root,
              doc: IReplyFacebookComment,
              { user, dataSources }: IContext
            ) {
          Severity: Minor
          Found in api/src/data/resolvers/mutations/conversations.ts - About 1 hr to fix

            Function conversationsUnassign has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async conversationsUnassign(
                _root,
                { _ids }: { _ids: string[] },
                { user }: IContext
              ) {
            Severity: Minor
            Found in api/src/data/resolvers/mutations/conversations.ts - About 1 hr to fix

              Function conversationsAssign has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async conversationsAssign(
                  _root,
                  {
                    conversationIds,
                    assignedUserId
              Severity: Minor
              Found in api/src/data/resolvers/mutations/conversations.ts - About 1 hr to fix

                Function conversationResolveAll has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async conversationResolveAll(_root, params: IListArgs, { user }: IContext) {
                    // initiate query builder
                    const qb = new QueryBuilder(params, { _id: user._id });
                
                    await qb.buildAllQueries();
                Severity: Minor
                Found in api/src/data/resolvers/mutations/conversations.ts - About 1 hr to fix

                  Function conversationsChangeStatus has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async conversationsChangeStatus(
                      _root,
                      { _ids, status }: { _ids: string[]; status: string },
                      { user }: IContext
                    ) {
                  Severity: Minor
                  Found in api/src/data/resolvers/mutations/conversations.ts - About 1 hr to fix

                    Function sendConversationToIntegrations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const sendConversationToIntegrations = async (
                      type: string,
                      integrationId: string,
                      conversationId: string,
                      requestName: string,
                    Severity: Minor
                    Found in api/src/data/resolvers/mutations/conversations.ts - About 45 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 2 locations. Consider refactoring.
                    Open

                        for (const conversation of updatedConversations) {
                          await putUpdateLog(
                            {
                              type: 'conversation',
                              description: 'change status',
                    Severity: Major
                    Found in api/src/data/resolvers/mutations/conversations.ts and 1 other location - About 1 hr to fix
                    api/src/data/resolvers/mutations/conversations.ts on lines 546..557

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

                    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

                        for (const conversation of conversations) {
                          await putUpdateLog(
                            {
                              type: 'conversation',
                              description: 'assignee Changed',
                    Severity: Major
                    Found in api/src/data/resolvers/mutations/conversations.ts and 1 other location - About 1 hr to fix
                    api/src/data/resolvers/mutations/conversations.ts on lines 630..641

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

                    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

                      async conversationsAssign(
                        _root,
                        {
                          conversationIds,
                          assignedUserId
                    Severity: Minor
                    Found in api/src/data/resolvers/mutations/conversations.ts and 2 other locations - About 40 mins to fix
                    api/src/data/resolvers/mutations/conversations.ts on lines 606..644
                    api/src/data/resolvers/mutations/notifications.ts on lines 22..43

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

                      async conversationsChangeStatus(
                        _root,
                        { _ids, status }: { _ids: string[]; status: string },
                        { user }: IContext
                      ) {
                    Severity: Minor
                    Found in api/src/data/resolvers/mutations/conversations.ts and 2 other locations - About 40 mins to fix
                    api/src/data/resolvers/mutations/conversations.ts on lines 520..560
                    api/src/data/resolvers/mutations/notifications.ts on lines 22..43

                    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