krautcomputing/skimlinks

View on GitHub
lib/skimlinks/client.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def get(api, path, params = {})
      raise Skimlinks::InvalidParameters, 'Only JSON format is supported right now.' unless Skimlinks.configuration.format == :json

      do_get = lambda do
        returning_json do
Severity: Minor
Found in lib/skimlinks/client.rb - About 2 hrs 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 merchant_search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def merchant_search(query, preferred = false)
      [].tap do |merchants|
        start, found = 0, nil

        while found.nil? || start < found
Severity: Minor
Found in lib/skimlinks/client.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 product_count_and_products has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def product_count_and_products(args)
      api_query = []
      api_query << %(id:(#{args[:ids].join(' ')}))                                                          if args[:ids].present?
      api_query << %((#{%w(title description).map { |field| %(#{field}:"#{args[:query]}") }.join(' OR ')})) if args[:query].present?
      api_query << %(price:[#{args[:min_price].presence || '*'} TO #{args[:max_price].presence || '*'}])    if args[:min_price].present? || args[:max_price].present?
Severity: Minor
Found in lib/skimlinks/client.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 merchants_in_category has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def merchants_in_category(category_id)
      [].tap do |merchants|
        start, found = 0, nil

        while found.nil? || start < found
Severity: Minor
Found in lib/skimlinks/client.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

There are no issues that match your filters.

Category
Status