zammad/zammad

View on GitHub

Showing 1,092 of 1,651 total issues

Method selector2sql has a Cognitive Complexity of 196 (exceeds 5 allowed). Consider refactoring.
Open

  def self.selector2sql(selectors, options = {})
    current_user = options[:current_user]
    current_user_id = UserInfo.current_user_id
    if current_user
      current_user_id = current_user.id
Severity: Minor
Found in app/models/ticket.rb - About 4 days 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 ticket.rb has 1411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Ticket < ApplicationModel
  include CanBeImported
  include HasActivityStreamLog
  include ChecksClientNotification
  include CanCsvImport
Severity: Major
Found in app/models/ticket.rb - About 3 days to fix

    Method perform_triggers has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.perform_triggers(ticket, article, item, options = {})
        recursive = Setting.get('ticket_trigger_recursive')
        type = options[:type] || item[:type]
        local_options = options.clone
        local_options[:type] = type
    Severity: Minor
    Found in app/models/ticket.rb - About 3 days 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 selector2query has a Cognitive Complexity of 136 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.selector2query(selector, options, aggs_interval)
        options = DEFAULT_QUERY_OPTIONS.merge(options.deep_symbolize_keys)
    
        current_user = options[:current_user]
        current_user_id = UserInfo.current_user_id
    Severity: Minor
    Found in lib/search_index_backend.rb - About 2 days 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 search_index_backend.rb has 972 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class SearchIndexBackend
    
      SUPPORTED_ES_VERSION_MINIMUM   = '7.8'.freeze
      SUPPORTED_ES_VERSION_LESS_THAN = '9'.freeze
    
    
    Severity: Major
    Found in lib/search_index_backend.rb - About 2 days to fix

      Method fetch has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
      Open

        def fetch(options, channel, check_type = '', verify_string = '')
          ssl            = true
          starttls       = false
          port           = 993
          keep_on_server = false
      Severity: Minor
      Found in app/models/channel/driver/imap.rb - About 2 days 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 send_email_notification has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
      Open

        def send_email_notification(value, article, perform_origin)
          # value['recipient'] was a string in the past (single-select) so we convert it to array if needed
          value_recipient = Array(value['recipient'])
      
          recipients_raw = []
      Severity: Minor
      Found in app/models/ticket.rb - About 2 days 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 user.rb has 852 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class User < ApplicationModel
        include CanBeAuthorized
        include CanBeImported
        include HasActivityStreamLog
        include ChecksClientNotification
      Severity: Major
      Found in app/models/user.rb - About 2 days to fix

        File FieldTreeSelect.spec.ts has 826 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
        
        import { cloneDeep } from 'lodash-es'
        import { getByText, waitFor } from '@testing-library/vue'
        import { FormKit } from '@formkit/vue'

          Method csv_import has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
          Open

              def csv_import(data)
                try    = data[:try].to_s == 'true'
                delete = data[:delete].to_s == 'true'
          
                begin
          Severity: Minor
          Found in app/models/concerns/can_csv_import.rb - 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

          File attribute.rb has 804 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class ObjectManager::Attribute < ApplicationModel
            include ChecksClientNotification
            include CanSeed
          
            DATA_TYPES = %w[
          Severity: Major
          Found in app/models/object_manager/attribute.rb - About 1 day to fix

            Method association_name_to_id_convert has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
            Open

                def association_name_to_id_convert(params)
            
                  if params.respond_to?(:permit!)
                    params = params.permit!.to_h
                  end
            Severity: Minor
            Found in app/models/application_model/can_associations.rb - 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

            File twitter_sync.rb has 761 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'http/uri'
            
            class TwitterSync
            
              STATUS_URL_TEMPLATE = 'https://twitter.com/_/status/%s'.freeze
            Severity: Major
            Found in lib/twitter_sync.rb - About 1 day to fix

              File email_parser.rb has 753 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class Channel::EmailParser
                PROZESS_TIME_MAX = 180
                EMAIL_REGEX = %r{.+@.+}
                RECIPIENT_FIELDS = %w[to cc delivered-to x-original-to envelope-to].freeze
                SENDER_FIELDS = %w[from reply-to return-path sender].freeze
              Severity: Major
              Found in app/models/channel/email_parser.rb - About 1 day to fix

                File types.ts has 710 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                export type Maybe<T> = T | null;
                export type InputMaybe<T> = Maybe<T>;
                export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
                export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
                export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
                Severity: Major
                Found in app/frontend/shared/graphql/types.ts - About 1 day to fix

                  File users_controller.rb has 708 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  class UsersController < ApplicationController
                    include ChecksUserAttributesByCurrentUserPermission
                    include CanPaginate
                  
                    prepend_before_action -> { authorize! }, only: %i[import_example import_start search history unlock]
                  Severity: Major
                  Found in app/controllers/users_controller.rb - About 1 day to fix

                    File FieldAutoComplete.spec.ts has 703 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
                    
                    import { cloneDeep, escapeRegExp } from 'lodash-es'
                    import { getByText, waitFor } from '@testing-library/vue'
                    import { FormKit } from '@formkit/vue'

                      Method selector2sql has 307 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.selector2sql(selectors, options = {})
                          current_user = options[:current_user]
                          current_user_id = UserInfo.current_user_id
                          if current_user
                            current_user_id = current_user.id
                      Severity: Major
                      Found in app/models/ticket.rb - About 1 day to fix

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

                          def perform
                        
                            # return if we run import mode
                            return if Setting.get('import_mode')
                        
                        
                        Severity: Minor
                        Found in app/models/transaction/slack.rb - 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

                        Method config has 303 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.config
                            config = {}
                            config[:metric] = {}
                        
                            config[:metric][:count] = {
                        Severity: Major
                        Found in app/models/report.rb - About 1 day to fix
                          Severity
                          Category
                          Status
                          Source
                          Language