3scale/porta

View on GitHub

Showing 5,267 of 5,597 total issues

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

    def debug_message(target, result)
      return if chain_config[:terminator].blank?
      conditions = []

      conditions.push "if: #{Array.wrap(@if).join(' && ')}" if @if.present?
Severity: Minor
Found in config/initializers/debug_callbacks.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 help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def help(assigns)
        assigns = Hash[
          assigns.map do |name, value|
            klass = value.class
            klass_name = if klass.respond_to?(:name)
Severity: Minor
Found in lib/developer_portal/lib/liquid/tags/debug.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 debug_callback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def debug_callback(callback)
      ->(target, *args, &block) do
        begin
          result = callback.call(target, *args, &block)
        rescue => e
Severity: Minor
Found in config/initializers/debug_callbacks.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

BulletSafeList::Offence#path is a writable attribute
Open

    attr_accessor :associations, :class_name, :method, :path, :text, :type
Severity: Minor
Found in script/bullet_safe_list.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Account::BillingAddress::Address#state is a writable attribute
Open

    attr_accessor :name, :address1, :address2, :city, :country, :state, :zip, :phone, :errors
Severity: Minor
Found in app/models/account/billing_address.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Account::BillingAddress::Address#zip is a writable attribute
Open

    attr_accessor :name, :address1, :address2, :city, :country, :state, :zip, :phone, :errors
Severity: Minor
Found in app/models/account/billing_address.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Account::BillingAddress#billing_address? performs a nil-check
Open

    !@billing_address_set.nil?
Severity: Minor
Found in app/models/account/billing_address.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Account::States#deliver_rejected_notification performs a nil-check
Open

    unless admins.empty? || self.provider_account.nil?
Severity: Minor
Found in app/models/account/states.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

DashboardTimeRange#time_window doesn't depend on instance state (maybe move it to another class?)
Open

  def time_window
Severity: Minor
Found in app/concerns/dashboard_time_range.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Ability has missing safe method 'load_rules!'
Open

  def load_rules!
Severity: Minor
Found in app/models/ability.rb by reek

A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

An exclamation mark in method names means (the explanation below is taken from here ):

The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

Example

Given

class C
  def foo; end
  def foo!; end
  def bar!; end
end

Reek would report bar! as Missing Safe Method smell but not foo!.

Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

class Parent
  def foo; end
end

module Dangerous
  def foo!; end
end

class Son < Parent
  include Dangerous
end

class Daughter < Parent
end

In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

Account::ProviderDomains#dedicated_domain is a writable attribute
Open

  attr_writer :dedicated_domain
Severity: Minor
Found in app/models/account/provider_domains.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Account::ProviderDomains#dedicated_domain performs a nil-check
Open

    if superdomain && !domain.nil? && domain.ends_with?(superdomain)
Severity: Minor
Found in app/models/account/provider_domains.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Account::ProviderMethods#signup is a writable attribute
Open

    attr_writer :signup
Severity: Minor
Found in app/models/account/provider_methods.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

HyperMegaProfiler#count_objects doesn't depend on instance state (maybe move it to another class?)
Open

  def count_objects
Severity: Minor
Found in script/hyper_mega_profiler.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Account::BillingAddress::Address#name is a writable attribute
Open

    attr_accessor :name, :address1, :address2, :city, :country, :state, :zip, :phone, :errors
Severity: Minor
Found in app/models/account/billing_address.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Alert#friendly_name performs a nil-check
Open

    metric.friendly_name unless metric.nil?
Severity: Minor
Found in app/models/alert.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

BulletSafeList::Offence#type is a writable attribute
Open

    attr_accessor :associations, :class_name, :method, :path, :text, :type
Severity: Minor
Found in script/bullet_safe_list.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Ability has missing safe method 'reload!'
Open

  def reload!
Severity: Minor
Found in app/models/ability.rb by reek

A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

An exclamation mark in method names means (the explanation below is taken from here ):

The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

Example

Given

class C
  def foo; end
  def foo!; end
  def bar!; end
end

Reek would report bar! as Missing Safe Method smell but not foo!.

Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

class Parent
  def foo; end
end

module Dangerous
  def foo!; end
end

class Son < Parent
  include Dangerous
end

class Daughter < Parent
end

In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

Account::BillingAddress::Address#address1 is a writable attribute
Open

    attr_accessor :name, :address1, :address2, :city, :country, :state, :zip, :phone, :errors
Severity: Minor
Found in app/models/account/billing_address.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

BulletSafeList::Offence#associations is a writable attribute
Open

    attr_accessor :associations, :class_name, :method, :path, :text, :type
Severity: Minor
Found in script/bullet_safe_list.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)
Severity
Category
Status
Source
Language