gupta-ankit/fitgem_oauth2

View on GitHub

Showing 72 of 72 total issues

Method body_time_series has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def body_time_series(resource: nil, start_date: nil, end_date: nil, period: nil)
      unless resource && start_date
        raise FitgemOauth2::InvalidArgumentError, 'resource and start_date are required parameters. Please specify both.'
      end

Severity: Minor
Found in lib/fitgem_oauth2/body_measurements.rb - About 1 hr 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

Method intraday_activity_time_series has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def intraday_activity_time_series(resource: nil, start_date: nil, end_date: nil, detail_level: nil,
                                      start_time: nil, end_time: nil)

      # converting to symbol to allow developer to use either 'calories' or :calories
      resource = resource.to_sym
Severity: Minor
Found in lib/fitgem_oauth2/activity.rb - About 1 hr to fix

    Method sleep_time_series has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def sleep_time_series(resource: nil, start_date: nil, end_date: nil, period: nil)
          raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.' unless start_date
    
          unless resource && SLEEP_RESOURCES.include?(resource)
            raise FitgemOauth2::InvalidArgumentError, "Invalid resource: #{resource}. Valid resources are #{SLEEP_RESOURCES}."
    Severity: Minor
    Found in lib/fitgem_oauth2/sleep.rb - About 55 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

    Method activity_time_series has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def activity_time_series(resource: nil, start_date: nil, end_date: nil, period: nil)
          unless resource && ACTIVITY_RESOURCES.include?(resource)
            raise FitgemOauth2::InvalidArgumentError, "Invalid resource: #{resource}. Valid resources are #{ACTIVITY_RESOURCES}."
          end
    
    
    Severity: Minor
    Found in lib/fitgem_oauth2/activity.rb - About 55 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

    Method intraday_series_guard has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def intraday_series_guard(start_date:, end_date:, detail_level:, start_time:, end_time:)
          raise FitgemOauth2::InvalidArgumentError, 'Start date not provided.' unless start_date
    
          unless detail_level && HR_DETAIL_LEVELS.include?(detail_level)
            raise FitgemOauth2::InvalidArgumentError, "Please specify the defail level. Detail level should be one of #{HR_DETAIL_LEVELS}."
    Severity: Minor
    Found in lib/fitgem_oauth2/heartrate.rb - About 45 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

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

        def activity_list(date, sort, limit)
          date_param = format_date(date)
          if sort == 'asc'
            date_param = "afterDate=#{date_param}"
          elsif sort == 'desc'
    Severity: Minor
    Found in lib/fitgem_oauth2/activity.rb and 1 other location - About 40 mins to fix
    lib/fitgem_oauth2/sleep.rb on lines 22..31

    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 38.

    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

        def sleep_logs_list(date, sort, limit)
          date_param = format_date(date)
          if sort == 'asc'
            date_param = "afterDate=#{date_param}"
          elsif sort == 'desc'
    Severity: Minor
    Found in lib/fitgem_oauth2/sleep.rb and 1 other location - About 40 mins to fix
    lib/fitgem_oauth2/activity.rb on lines 117..126

    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 38.

    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

    Method body_fat_logs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def body_fat_logs(start_date: nil, end_date: nil, period: nil)
          raise FitgemOauth2::InvalidArgumentError, 'must specify start_date' unless start_date
    
          url = ['user', user_id, 'body/log/fat/date', format_date(start_date)].join('/')
          url = [url, format_date(end_date)].join('/') if end_date
    Severity: Minor
    Found in lib/fitgem_oauth2/body_measurements.rb - About 35 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

    Avoid parameter lists longer than 5 parameters. [6/5]
    Open

        def intraday_activity_time_series(resource: nil, start_date: nil, end_date: nil, detail_level: nil,
                                          start_time: nil, end_time: nil)
    Severity: Minor
    Found in lib/fitgem_oauth2/activity.rb by rubocop

    This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

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

        def format_date(date)
          return nil if date.nil?
    
          valid_semantic_date = %w[today yesterday].include? date
          valid_date_string = (date =~ /\d{4}\-\d{2}\-\d{2}/) == 0
    Severity: Minor
    Found in lib/fitgem_oauth2/utils.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

    Line is too long. [121/120]
    Open

        # @param period the period starting from start_date for which the series needs to be retrieved. If specifying period,
    Severity: Minor
    Found in lib/fitgem_oauth2/activity.rb by rubocop

    Missing top-level class documentation comment.
    Open

      class Client
    Severity: Minor
    Found in lib/fitgem_oauth2/utils.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Missing top-level class documentation comment.
    Open

      class Client
    Severity: Minor
    Found in lib/fitgem_oauth2/food/metadata.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Line is too long. [137/120]
    Open

        # @param resource (required) for which the intrady series is retrieved. one of 'calories', 'steps', 'distance', 'floors', 'elevation'
    Severity: Minor
    Found in lib/fitgem_oauth2/activity.rb by rubocop

    Line is too long. [122/120]
    Open

            raise FitgemOauth2::InvalidArgumentError, "Invalid resource: #{resource}. Valid resources are #{SLEEP_RESOURCES}."
    Severity: Minor
    Found in lib/fitgem_oauth2/sleep.rb by rubocop

    Missing top-level class documentation comment.
    Open

      class Client
    Severity: Minor
    Found in lib/fitgem_oauth2/devices.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Line is too long. [129/120]
    Open

            raise FitgemOauth2::InvalidArgumentError, "Invalid period: #{period}. Specify a valid period from #{FOOD_SERIES_PERIODS}"
    Severity: Minor
    Found in lib/fitgem_oauth2/food.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

        DEFAULT_USER_ID = '-'
    Severity: Minor
    Found in lib/fitgem_oauth2/client.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Missing top-level class documentation comment.
    Open

      class Client
    Severity: Minor
    Found in lib/fitgem_oauth2/friends.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Missing top-level class documentation comment.
    Open

      class Client

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end
    Severity
    Category
    Status
    Source
    Language