chatwoot/chatwoot

View on GitHub

Showing 25 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

        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

          Class Message has 34 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

            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

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

              if (window.errorLoggingConfig) {
                Sentry.init({
                  Vue,
                  dsn: window.errorLoggingConfig,
                  denyUrls: [
              Severity: Major
              Found in app/javascript/packs/v3app.js and 1 other location - About 2 hrs to fix
              app/javascript/packs/application.js on lines 37..59

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

              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

              if (window.errorLoggingConfig) {
                Sentry.init({
                  Vue,
                  dsn: window.errorLoggingConfig,
                  denyUrls: [
              Severity: Major
              Found in app/javascript/packs/application.js and 1 other location - About 2 hrs to fix
              app/javascript/packs/v3app.js on lines 20..42

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

              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

              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

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

                        const getters = {
                          isLoggedIn: true,
                          getCurrentUser: {
                            account_id: 1,
                            id: 1,
              Severity: Minor
              Found in app/javascript/dashboard/routes/index.spec.js and 1 other location - About 50 mins to fix
              app/javascript/dashboard/routes/index.spec.js on lines 36..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 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

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

                        const getters = {
                          isLoggedIn: true,
                          getCurrentUser: {
                            account_id: 1,
                            id: 1,
              Severity: Minor
              Found in app/javascript/dashboard/routes/index.spec.js and 1 other location - About 50 mins to fix
              app/javascript/dashboard/routes/index.spec.js on lines 53..60

              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

              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

                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

                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

                Severity
                Category
                Status
                Source
                Language