3scale/porta

View on GitHub

Showing 5,267 of 5,597 total issues

MinitestWorld#assertions is a writable attribute
Open

  attr_writer :assertions
Severity: Minor
Found in features/support/minitest.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)

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

  def up

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

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

def buyer_makes_service_transactions(buyer_account, count, table)

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

DeveloperPortal::SignupController has missing safe method 'signup_user!'
Open

    def signup_user!(account_params, user_params)

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.

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

  def generate_application_keys(number)

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

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

  def slow_requests

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

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

  def dom_id(object)
Severity: Minor
Found in features/support/record_identifier.rb by reek

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

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

  def rack_test?

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

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

  def block_requests

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

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

  def create_plan(type, options)
Severity: Minor
Found in features/support/plan_helpers.rb by reek

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

Liquid::Filters::GoogleAnalytics#embed_google_tracker doesn't depend on instance state (maybe move it to another class?)
Open

      def embed_google_tracker(code)

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

Liquid::Tags::ActiveDocs#initialize performs a nil-check
Open

          @services = $2.nil? ? [] : $2.split(",").map(&:strip)

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)

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

  def fake_application_keys(application, keys)

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

CMS::Toolbar#cms_toolbar_enabled? performs a nil-check
Open

    is_html_content = response.media_type.nil? || response.media_type == 'text/html' #=> only for html content type

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)

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

  def underscore_spaces(name)

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

DeveloperPortal::Admin::Account::PlanChangesController has missing safe method 'remember_plan_change!'
Open

    def remember_plan_change!

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.

Liquid::Tags::ContentFor::ContentFor#stylesheets doesn't depend on instance state (maybe move it to another class?)
Open

      def stylesheets

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

Liquid::Drops::Collection inherits from core class 'Array'
Open

    class Collection < Array

Subclassing core classes in Ruby can lead to unexpected side effects.

Knowing that Ruby has a core library, which is written in C, and a standard library, which is written in Ruby, if you do not know exactly how these core classes operate at the C level, you are gonna have a bad time.

Source: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes

Liquid::Filters::RailsHelpers#html_safe doesn't depend on instance state (maybe move it to another class?)
Open

      def html_safe(output)

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

Liquid::Tags::ContentFor::ContentFor#javascripts doesn't depend on instance state (maybe move it to another class?)
Open

      def javascripts

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

Severity
Category
Status
Source
Language