natydev/fitbark

View on GitHub

Showing 145 of 145 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  module Handler
    module V2
      # = \#dog_picture
      # Fitbark::Handler::V2::DogPicture define method *dog_picture*
      # inside Client object
Severity: Minor
Found in lib/fitbark/handler/v2/dog_picture.rb and 2 other locations - About 35 mins to fix
lib/fitbark/handler/v2/dog_info.rb on lines 2..34
lib/fitbark/handler/v2/user_picture.rb on lines 2..34

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  module Handler
    module V2
      # = \#dog_info
      # Fitbark::Handler::V2::DogInfo define method *dog_info*
      # inside Client object
Severity: Minor
Found in lib/fitbark/handler/v2/dog_info.rb and 2 other locations - About 35 mins to fix
lib/fitbark/handler/v2/dog_picture.rb on lines 2..34
lib/fitbark/handler/v2/user_picture.rb on lines 2..34

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Handler
    module V2
      # = \#user_relations
      # Fitbark::Handler::V2::DogRelations define method *user_relations*
      # inside Client object
Severity: Minor
Found in lib/fitbark/handler/v2/user_relations.rb and 1 other location - About 30 mins to fix
lib/fitbark/handler/v2/daily_goals.rb on lines 2..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Handler
    module V2
      # = \#daily_goals
      # Fitbark::Handler::V2::DailyGoals define method *daily_goals*
      # inside Client object
Severity: Minor
Found in lib/fitbark/handler/v2/daily_goals.rb and 1 other location - About 30 mins to fix
lib/fitbark/handler/v2/user_relations.rb on lines 2..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      def time_parser(attr)
Severity: Minor
Found in lib/fitbark/data/shared.rb by reek

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

Fitbark::Handler::V2::SetDailyGoal#build_params doesn't depend on instance state (maybe move it to another class?)
Open

        def build_params(goal_points, set_on)

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

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.

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

        def validate_input
          unless RESOLUTIONS.include? resolution
            raise(Fitbark::Errors::FormatError
              .new(message: "Wrong or missing param 'resolution', must be kind of:
               #{Fitbark::Handler::V2::ActivitySeries::RESOLUTIONS.join(', ')}"))
Severity: Minor
Found in lib/fitbark/handler/v2/activity_series.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

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

      def init_breed(attr)
Severity: Minor
Found in lib/fitbark/data/shared.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::Handler::V2::ActivitySeries#format_resolution doesn't depend on instance state (maybe move it to another class?)
Open

        def format_resolution(val)

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

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::Constants#camel doesn't depend on instance state (maybe move it to another class?)
Open

    def camel(str)
Severity: Minor
Found in lib/fitbark/constants.rb by reek

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

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

      def date_parser(attr)
Severity: Minor
Found in lib/fitbark/data/shared.rb by reek

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

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.

Fitbark::Errors::BaseError#code is a writable attribute
Open

      attr_accessor :message, :code
Severity: Minor
Found in lib/fitbark/errors.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::Errors::BaseError#message is a writable attribute
Open

      attr_accessor :message, :code
Severity: Minor
Found in lib/fitbark/errors.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::Client#initialize performs a nil-check
Open

      raise Fitbark::Errors::TokenNotProvidedError if token.nil?
Severity: Minor
Found in lib/fitbark/client.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::Data::Shared#init_medical_condition doesn't depend on instance state (maybe move it to another class?)
Open

      def init_medical_condition(attr)
Severity: Minor
Found in lib/fitbark/data/shared.rb by reek

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

Severity
Category
Status
Source
Language