3scale/porta

View on GitHub
app/lib/authenticated_system.rb

Summary

Maintainability
A
0 mins
Test Coverage

AuthenticatedSystem#logout_keeping_session! manually dispatches method call
Open

    @current_user.forget_me if @current_user.respond_to?(:forget_me)
Severity: Minor
Found in app/lib/authenticated_system.rb by reek

Reek reports a Manual Dispatch smell if it finds source code that manually checks whether an object responds to a method before that method is called. Manual dispatch is a type of Simulated Polymorphism which leads to code that is harder to reason about, debug, and refactor.

Example

class MyManualDispatcher
  attr_reader :foo

  def initialize(foo)
    @foo = foo
  end

  def call
    foo.bar if foo.respond_to?(:bar)
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [9]: MyManualDispatcher manually dispatches method call (ManualDispatch)

AuthenticatedSystem#self.included manually dispatches method call
Open

                    :logged_in?, :owner?, :current_site, :admin? if respond_to?(:helper_method)
Severity: Minor
Found in app/lib/authenticated_system.rb by reek

Reek reports a Manual Dispatch smell if it finds source code that manually checks whether an object responds to a method before that method is called. Manual dispatch is a type of Simulated Polymorphism which leads to code that is harder to reason about, debug, and refactor.

Example

class MyManualDispatcher
  attr_reader :foo

  def initialize(foo)
    @foo = foo
  end

  def call
    foo.bar if foo.respond_to?(:bar)
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [9]: MyManualDispatcher manually dispatches method call (ManualDispatch)

AuthenticatedSystem#login_from_remember_me_cookie calls 'cookies[:auth_token]' 2 times
Open

    user = cookies[:auth_token] && defined?(site_account) && site_account.managed_users.find_by_remember_token(cookies[:auth_token])
Severity: Minor
Found in app/lib/authenticated_system.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

AuthenticatedSystem#redirect_to_login_for_buyers calls 'site_account.settings' 2 times
Open

    if site_account.settings.sso_login_url.blank?
      redirect_to developer_portal.login_path
    else
      redirect_to site_account.settings.sso_login_url
Severity: Minor
Found in app/lib/authenticated_system.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

AuthenticatedSystem#redirect_to_login_for_buyers calls 'site_account.settings.sso_login_url' 2 times
Open

    if site_account.settings.sso_login_url.blank?
      redirect_to developer_portal.login_path
    else
      redirect_to site_account.settings.sso_login_url
Severity: Minor
Found in app/lib/authenticated_system.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

There are no issues that match your filters.

Category
Status