chatwoot/chatwoot

View on GitHub

Showing 18 of 25 total issues

File actions.js has 405 lines of code (exceeds 300 allowed). Consider refactoring.
Open

import Vue from 'vue';
import types from '../../mutation-types';
import ConversationApi from '../../../api/inbox/conversation';
import MessageApi from '../../../api/inbox/message';
import { MESSAGE_STATUS, MESSAGE_TYPE } from 'shared/constants/messages';
Severity: Minor
Found in app/javascript/dashboard/store/modules/conversations/actions.js - About 4 hrs to fix

    Function runSDK has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    const runSDK = ({ baseUrl, websiteToken }) => {
      if (window.$chatwoot) {
        return;
      }
    
    
    Severity: Minor
    Found in app/javascript/packs/sdk.js - About 4 hrs 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

    File conversationHotKeys.js has 369 lines of code (exceeds 300 allowed). Consider refactoring.
    Open

    import { mapGetters } from 'vuex';
    import wootConstants from 'dashboard/constants/globals';
    
    import { CMD_AI_ASSIST } from './commandBarBusEvents';
    import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';

      actions has 38 functions (exceeds 32 allowed). Consider refactoring.
      Open

      const actions = {
        getConversation: async ({ commit }, conversationId) => {
          try {
            const response = await ConversationApi.show(conversationId);
            commit(types.UPDATE_CONVERSATION, response.data);
      Severity: Minor
      Found in app/javascript/dashboard/store/modules/conversations/actions.js - About 3 hrs to fix

        Function buildMentionTokens has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        const buildMentionTokens = () => (state, silent) => {
          var label;
          var labelEnd;
          var labelStart;
          var pos;
        Severity: Minor
        Found in app/javascript/shared/helpers/markdownIt/link.js - About 2 hrs 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

        Class Message has 35 methods (exceeds 32 allowed). Consider refactoring.
        Open

        class Message < ApplicationRecord
          include MessageFilterHelpers
          include Liquidable
          NUMBER_OF_PERMITTED_ATTACHMENTS = 15
        
        
        Severity: Minor
        Found in app/models/message.rb - About 2 hrs to fix

          mutations has 35 functions (exceeds 32 allowed). Consider refactoring.
          Open

          export const mutations = {
            [types.SET_ALL_CONVERSATION](_state, conversationList) {
              const newAllConversations = [..._state.allConversations];
              conversationList.forEach(conversation => {
                const indexInCurrentList = newAllConversations.findIndex(
          Severity: Minor
          Found in app/javascript/dashboard/store/modules/conversations/index.js - About 2 hrs to fix

            File methodsMixin.js has 305 lines of code (exceeds 300 allowed). Consider refactoring.
            Open

            import languages from 'dashboard/components/widgets/conversation/advancedFilterItems/languages';
            import countries from 'shared/constants/countries';
            import {
              generateCustomAttributeTypes,
              getActionOptions,
            Severity: Minor
            Found in app/javascript/dashboard/mixins/automations/methodsMixin.js - About 2 hrs to fix

              Method perform has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def perform
                  return false unless rule_valid?
              
                  @attribute_changed_query_filter = []
              
              
              Severity: Minor
              Found in app/services/automation_rules/conditions_filter_service.rb - 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 buildCreatePayload has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export const buildCreatePayload = ({
                message,
                isPrivate,
                contentAttributes,
                echoId,
              Severity: Minor
              Found in app/javascript/dashboard/api/inbox/message.js - About 55 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

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

                sortOnWaitingSince: (a, b, sortDirection) => {
                  const sortFunc = getSortOrderFunction(sortDirection);
                  if (!a.waiting_since || !b.waiting_since) {
                    if (!a.waiting_since && !b.waiting_since) {
                      return sortFunc(a.created_at, b.created_at);
              Severity: Minor
              Found in app/javascript/dashboard/store/modules/conversations/helpers.js - 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

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

              export const conversationUrl = ({
                accountId,
                activeInbox,
                id,
                label,
              Severity: Minor
              Found in app/javascript/dashboard/helper/URLHelper.js - 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

              Method find_all has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def find_all(name, prefix = nil, partial = false, details = {}, key = nil, locals = [])
              Severity: Minor
              Found in app/services/email_templates/db_resolver_service.rb - About 45 mins to fix

                Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def update
                    ActiveRecord::Base.transaction do
                      @portal.update!(portal_params) if params[:portal].present?
                      # @portal.custom_domain = parsed_custom_domain
                      process_attached_logo if params[:blob_id].present?
                Severity: Minor
                Found in app/controllers/api/v1/accounts/portals_controller.rb - 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

                Method contact_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def contact_params
                    begin
                      k = Koala::Facebook::API.new(@inbox.channel.page_access_token) if @inbox.facebook?
                      result = k.get_object(@sender_id) || {}
                    rescue Koala::Facebook::AuthenticationError => e
                Severity: Minor
                Found in app/builders/messages/facebook/message_builder.rb - 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

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

                    manifestConditions(automation) {
                      const customAttributes = filterCustomAttributes(this.allCustomAttributes);
                      const conditions = automation.conditions.map(condition => {
                        const customAttr = isCustomAttribute(
                          customAttributes,
                Severity: Minor
                Found in app/javascript/dashboard/mixins/automations/methodsMixin.js - 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

                Avoid too many return statements within this method.
                Open

                    return :contact if ['contacts'].include?(file_type)
                Severity: Major
                Found in app/services/whatsapp/incoming_message_service_helpers.rb - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return [item.values];
                  Severity: Major
                  Found in app/javascript/dashboard/helper/filterQueryGenerator.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language