zammad/zammad

View on GitHub

Showing 2,071 of 4,482 total issues

Method activity_stream_update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def activity_stream_update
    return true if !saved_changes?

    ignored_attributes  = self.class.instance_variable_get(:@activity_stream_attributes_ignored) || []
    ignored_attributes += %i[created_at updated_at created_by_id updated_by_id]
Severity: Minor
Found in app/models/concerns/has_activity_stream_log.rb - About 25 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 gracefully_get_attachments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def gracefully_get_attachments(part, attachments, mail)
    get_attachments(part, attachments, mail).flatten.compact
  rescue => e # Protect process to work with spam emails (see test/fixtures/mail15.box)
    raise e if (fail_count ||= 0).positive?

Severity: Minor
Found in app/models/channel/email_parser.rb - About 25 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 check_default_organization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def check_default_organization
    return if !has_attribute?(:organization_id)
    return if !customer_id

    customer = User.find_by(id: customer_id)
Severity: Minor
Found in app/models/ticket.rb - About 25 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 check_owner_active has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def check_owner_active
    return true if Setting.get('import_mode')

    # only change the owner for non closed Tickets for historical/reporting reasons
    return true if state.present? && Ticket::StateType.lookup(id: state.state_type_id)&.name == 'closed'
Severity: Minor
Found in app/models/ticket.rb - About 25 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 generate_uniq_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_uniq_name(name)
      return name if !exists?(name: name)

      (1..100).each do |counter|
        name = "#{name}_#{counter}"
Severity: Minor
Found in app/models/concerns/can_uniq_name.rb - About 25 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 agent_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def agent_user
    return if user_id.blank?

    user = User.lookup(id: user_id)
    return if user.blank?
Severity: Minor
Found in app/models/chat/session.rb - About 25 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 available_agents_with_concurrent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.available_agents_with_concurrent(chat_ids, diff = 2.minutes)
    agents = {}
    Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each do |record|
      user = User.lookup(id: record.updated_by_id)
      next if !user
Severity: Minor
Found in app/models/chat.rb - About 25 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 agent_active_chat_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.agent_active_chat_ids(user)
    return [] if user.preferences[:chat].blank?
    return [] if user.preferences[:chat][:active].blank?

    chat_ids = []
Severity: Minor
Found in app/models/chat.rb - About 25 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 active_agent_count has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.active_agent_count(chat_ids, diff = 2.minutes)
    count = 0
    Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each do |record|
      user = User.lookup(id: record.updated_by_id)
      next if !user
Severity: Minor
Found in app/models/chat.rb - About 25 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 po_files_for_locale has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def po_files_for_locale(locale)
      return ['i18n/zammad.pot'] if locale.eql? 'en-us'

      locale_name = locale

Severity: Minor
Found in app/models/translation/synchronizes_from_po.rb - About 25 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 rearrangement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def rearrangement
    # rearrange only in case of changed prio
    return true if !changes['prio']

    rearranged_prio = 0
Severity: Minor
Found in app/models/concerns/can_priorization.rb - About 25 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 update_referenced_objects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.update_referenced_objects(old_name, new_name)
    objects = Overview.all + Trigger.all + Job.all + PostmasterFilter.all

    objects.each do |object|
      changed = false
Severity: Minor
Found in app/models/tag/item.rb - About 25 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 update_condition_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.update_condition_hash(hash, old_name, new_name)
    changed = false
    hash.each do |key, condition|
      next if %w[ticket.tags x-zammad-ticket-tags].exclude? key
      next if condition[:value].split(', ').exclude? old_name
Severity: Minor
Found in app/models/tag/item.rb - About 25 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 deliver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def deliver(_options, attr, notification = false)

    # return if we run import mode
    return if Setting.get('import_mode')

Severity: Minor
Found in app/models/channel/driver/sendmail.rb - About 25 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 access has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def access(*access)
        table_name = proxy_association.owner.class.group_through.table_name
        query      = select("#{ActiveRecord::Base.connection.quote_table_name('groups')}.*, #{ActiveRecord::Base.connection.quote_table_name(table_name)}.*")
        return query if access.blank?

Severity: Minor
Found in app/models/concerns/has_groups.rb - About 25 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 active_agents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.active_agents(chat_ids, diff = 2.minutes)
    users = []
    Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each do |record|
      user = User.lookup(id: record.updated_by_id)
      next if !user
Severity: Minor
Found in app/models/chat.rb - About 25 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 queue_registered has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.queue_registered
    backends.each do |backend|

      # skip backends that are not "ready" yet
      next if !backend.constantize.queueable?
Severity: Minor
Found in app/models/import_job.rb - About 25 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 user_create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.user_create(attrs, role_ids = nil)
    populate_attributes!(attrs, role_ids: role_ids)

    if attrs[:login]
      attrs[:login] = EmailHelper::Idn.to_unicode(attrs[:login])
Severity: Minor
Found in app/models/channel/filter/identify_sender.rb - About 25 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 for_ticket has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.for_ticket(ticket)
    fallback = nil
    all.reorder(:name, :created_at).as_batches(size: 10) do |record|
      if record.condition.present?
        return record if record.condition_matches?(ticket)
Severity: Minor
Found in app/models/sla.rb - About 25 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 recipients_active? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def recipients_active?
    return true if !preferences
    return true if !preferences[:participants]

    count = 0
Severity: Minor
Found in app/models/chat/session.rb - About 25 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