gupta-ankit/fitgem_oauth2

View on GitHub

Showing 72 of 72 total issues

Assignment Branch Condition size for parse_response is too high. [31.64/15]
Open

    def parse_response(response)
      headers_to_keep = %w[fitbit-rate-limit-limit fitbit-rate-limit-remaining fitbit-rate-limit-reset]

      error_handler = {
        200 => lambda {
Severity: Minor
Found in lib/fitgem_oauth2/client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [27/20]
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 by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [25/20]
Open

    def parse_response(response)
      headers_to_keep = %w[fitbit-rate-limit-limit fitbit-rate-limit-remaining fitbit-rate-limit-reset]

      error_handler = {
        200 => lambda {
Severity: Minor
Found in lib/fitgem_oauth2/client.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for activity_time_series is too high. [9/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for sleep_time_series is too high. [9/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for weight_logs is too high. [9/6]
Open

    def weight_logs(start_date: nil, end_date: nil, period: nil)
      raise FitgemOauth2::InvalidArgumentError, 'start_date not specified.' unless start_date

      if period && end_date
        raise FitgemOauth2::InvalidArgumentError, 'both end_date and period specified. please provide only one.'

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for body_time_series is too high. [9/7]
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

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Cyclomatic complexity for body_time_series is too high. [8/6]
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

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for weight_logs is too high. [9/7]
Open

    def weight_logs(start_date: nil, end_date: nil, period: nil)
      raise FitgemOauth2::InvalidArgumentError, 'start_date not specified.' unless start_date

      if period && end_date
        raise FitgemOauth2::InvalidArgumentError, 'both end_date and period specified. please provide only one.'

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Perceived complexity for activity_time_series is too high. [9/7]
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 by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Perceived complexity for sleep_time_series is too high. [9/7]
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 by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Cyclomatic complexity for intraday_series_guard is too high. [8/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for format_date is too high. [8/7]
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 by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Cyclomatic complexity for intraday_activity_time_series is too high. [7/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for format_date is too high. [7/6]
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 by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for intraday_series_guard is too high. [8/7]
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 by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Assignment Branch Condition size for sleep_time_series is too high. [15.39/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for activity_time_series is too high. [15.56/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

    def weight_logs(start_date: nil, end_date: nil, period: nil)
      raise FitgemOauth2::InvalidArgumentError, 'start_date not specified.' unless start_date

      if period && end_date
        raise FitgemOauth2::InvalidArgumentError, 'both end_date and period specified. please provide only one.'
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 a Cognitive Complexity of 10 (exceeds 5 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

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

Severity
Category
Status
Source
Language