krautcomputing/skimlinks

View on GitHub

Showing 7 of 9 total issues

Method search_params has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def search_params(args = {})
      args = args.dup.reverse_merge(
        ATTRIBUTES.each_with_object({}) do |attribute, hash|
          hash[attribute.to_sym] = self.send(attribute) unless self.send(attribute).nil?
        end
Severity: Minor
Found in lib/skimlinks/product_search.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 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 merchants has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def merchants(args = {})
      args = args.dup.reverse_merge(
        ATTRIBUTES.each_with_object({}) do |attribute, hash|
          hash[attribute.to_sym] = self.send(attribute) unless self.send(attribute).nil?
        end
Severity: Minor
Found in lib/skimlinks/merchant_search.rb - About 1 hr to fix

    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 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 merchants has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def merchants(args = {})
          args = args.dup.reverse_merge(
            ATTRIBUTES.each_with_object({}) do |attribute, hash|
              hash[attribute.to_sym] = self.send(attribute) unless self.send(attribute).nil?
            end
    Severity: Minor
    Found in lib/skimlinks/merchant_search.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

    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

    Severity
    Category
    Status
    Source
    Language