3scale/porta

View on GitHub

Showing 5,267 of 5,597 total issues

Provider::Admin::ApiDocsIndexPresenter#props performs a nil-check
Open

      isAudience: service.nil?

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)

ImportCountriesService has missing safe method 'call!'
Open

  def call!

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.

Notifications::NewNotificationSystemMigration has missing safe method 'migrate!'
Open

  def migrate!

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.

Authentication::Strategy::Base#signup_path doesn't depend on instance state (maybe move it to another class?)
Open

      def signup_path(params)

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

Authentication::ModelClassMethods#secure_digest doesn't depend on instance state (maybe move it to another class?)
Open

    def secure_digest(*args)
Severity: Minor
Found in app/lib/authentication.rb by reek

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

TrafficService takes parameters ['since', 'till'] to 3 methods
Open

  def per_day(since: , till: nil, metric_name: self.metric_name)
    till ||= now

    usage = stats_client.usage(
        metric_name: metric_name,
Severity: Minor
Found in app/services/traffic_service.rb by reek

In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

Example

Given

class Dummy
  def x(y1,y2); end
  def y(y1,y2); end
  def z(y1,y2); end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

A possible way to fix this problem (quoting from Martin Fowler):

The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

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

  def now
Severity: Minor
Found in app/services/traffic_service.rb by reek

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

Authentication::Strategy::Cas#on_signup_complete doesn't depend on instance state (maybe move it to another class?)
Open

      def on_signup_complete session
Severity: Minor
Found in app/lib/authentication/strategy/cas.rb by reek

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

Backend::RandomDataGenerator#self.find_metric performs a nil-check
Open

      when nil

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)

CMS::S3#fips_environment? doesn't depend on instance state (maybe move it to another class?)
Open

    def fips_environment?
Severity: Minor
Found in app/lib/cms/s3.rb by reek

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

Csv::BuyersExporter#values_for_account doesn't depend on instance state (maybe move it to another class?)
Open

  def values_for_account(account)
Severity: Minor
Found in app/lib/csv/buyers_exporter.rb by reek

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

BackendClient::Request#max_tries doesn't depend on instance state (maybe move it to another class?)
Open

    def max_tries
Severity: Minor
Found in app/lib/backend_client/request.rb by reek

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

Csv::Exporter#output_encoding doesn't depend on instance state (maybe move it to another class?)
Open

  def output_encoding
Severity: Minor
Found in app/lib/csv/exporter.rb by reek

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

EventStore::Repository::Facade takes parameters ['event', 'stream_name'] to 3 methods
Open

      def publish_event(event, stream_name = RubyEventStore::GLOBAL_STREAM, expected_version = :any)
        logger.debug { "[EventStore] publishing #{event.class} #{event.event_id}" } if event

        append_to_stream(stream_name, event, expected_version)
        event_broker.notify_subscribers(event)
Severity: Minor
Found in app/lib/event_store/repository.rb by reek

In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

Example

Given

class Dummy
  def x(y1,y2); end
  def y(y1,y2); end
  def z(y1,y2); end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

A possible way to fix this problem (quoting from Martin Fowler):

The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

Fields::BaseField#label is a writable attribute
Open

  attr_accessor :name, :label, :type, :required, :choices, :hint, :hidden, :options
Severity: Minor
Found in app/lib/fields/base_field.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)

Csv::ApplicationsExporter#values_for doesn't depend on instance state (maybe move it to another class?)
Open

  def values_for(admin, cinstance, buyer)
Severity: Minor
Found in app/lib/csv/applications_exporter.rb by reek

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

Csv::MessagesExporter#generate performs a nil-check
Open

      data = @account.received_messages.where(@range.nil? ? {} : {:"messages.created_at" => @range})
                                       .joins(:message)
                                       .merge(Message.order(created_at: :desc)).find_each do |d|
        detail = if d.sender.nil? || d.sender.admins.first.nil?
Severity: Minor
Found in app/lib/csv/messages_exporter.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)

Fields::Fields#fields_definitions_source is a writable attribute
Open

    attr_writer :fields_definitions_source
Severity: Minor
Found in app/lib/fields/fields.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)

Fields::FormBuilder#field performs a nil-check
Open

    output_html(field, options).html_safe unless field.nil?
Severity: Minor
Found in app/lib/fields/form_builder.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)

Finance::Builder::XmlMarkup has missing safe method 'date!'
Open

  def date!(xml, name, value)
Severity: Minor
Found in app/lib/finance/builder/xml_markup.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.

Severity
Category
Status
Source
Language