natydev/fitbark

View on GitHub
lib/fitbark/auth.rb

Summary

Maintainability
A
0 mins
Test Coverage

Fitbark::Auth has at least 8 instance variables
Open

  class Auth
Severity: Minor
Found in lib/fitbark/auth.rb by reek

Too Many Instance Variables is a special case of LargeClass.

Example

Given this configuration

TooManyInstanceVariables:
  max_instance_variables: 3

and this code:

class TooManyInstanceVariables
  def initialize
    @arg_1 = :dummy
    @arg_2 = :dummy
    @arg_3 = :dummy
    @arg_4 = :dummy
  end
end

Reek would emit the following warning:

test.rb -- 5 warnings:
  [1]:TooManyInstanceVariables has at least 4 instance variables (TooManyInstanceVariables)

Fitbark::Auth#read_token manually dispatches method call
Open

      (token_data.respond_to?(:token) && token_data.token) || val
Severity: Minor
Found in lib/fitbark/auth.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)

Fitbark::Auth#code is a writable attribute
Open

    attr_accessor :code
Severity: Minor
Found in lib/fitbark/auth.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)

Fitbark::Auth#parsed_body doesn't depend on instance state (maybe move it to another class?)
Open

    def parsed_body(resp)
Severity: Minor
Found in lib/fitbark/auth.rb by reek

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

Fitbark::Auth#token_info_response performs a nil-check
Open

      raise Fitbark::Errors::TokenNotProvidedError if token.nil?
Severity: Minor
Found in lib/fitbark/auth.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)

Fitbark::Auth#token is a writable attribute
Open

    attr_writer :token
Severity: Minor
Found in lib/fitbark/auth.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)

Fitbark::Auth has missing safe method 'fetch_access_token!'
Open

    def fetch_access_token!
Severity: Minor
Found in lib/fitbark/auth.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.

Line is too long. [84/80]
Open

    #     auth = Fitbark::Auth.new(client_id: client_id, redirect_uri: redirect_uri)
Severity: Minor
Found in lib/fitbark/auth.rb by rubocop

Trailing whitespace detected.
Open

    # Once that authorization uri was open and fetched the authorization 
Severity: Minor
Found in lib/fitbark/auth.rb by rubocop

Line is too long. [90/80]
Open

    #                              code: authorization_code, client_secret: client_secret)
Severity: Minor
Found in lib/fitbark/auth.rb by rubocop

Line is too long. [82/80]
Open

    #   auth = Fitbark::Auth.new(client_id: client_id, redirect_uri: redirect_uri,
Severity: Minor
Found in lib/fitbark/auth.rb by rubocop

Trailing whitespace detected.
Open

    # 
Severity: Minor
Found in lib/fitbark/auth.rb by rubocop

There are no issues that match your filters.

Category
Status