mhuggins/a2z

View on GitHub

Showing 17 of 17 total issues

Method from_response has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def self.from_response(data)
        new.tap do |browse_node|
          if data
            browse_node.id   = data['BrowseNodeId']
            browse_node.name = data['Name']
Severity: Minor
Found in lib/a2z/responses/browse_node.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 from_response has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def self.from_response(data)
        new.tap do |item|
          item.asin = data['ASIN']
          item.parent_asin = data['ParentASIN']
          item.detail_page_url = data['DetailPageURL']
Severity: Minor
Found in lib/a2z/responses/item.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 from_response has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.from_response(data)
        new.tap do |item|
          item.asin = data['ASIN']
          item.parent_asin = data['ParentASIN']
          item.detail_page_url = data['DetailPageURL']
Severity: Minor
Found in lib/a2z/responses/item.rb - About 1 hr to fix

    Method from_response has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.from_response(data)
            new.tap do |browse_node|
              if data
                browse_node.id   = data['BrowseNodeId']
                browse_node.name = data['Name']
    Severity: Minor
    Found in lib/a2z/responses/browse_node.rb - About 1 hr to fix

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

            def self.from_response(data)
              new.tap do |offer|
                if (attributes = data['OfferAttributes'])
                  offer.condition = attributes['Condition']
                end
      Severity: Minor
      Found in lib/a2z/responses/offer.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 from_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.from_response(data)
              new.tap do |item_search|
                item_search.operation_request       = OperationRequest.from_response(data['OperationRequest']) if data['OperationRequest']
                item_search.items                   = items_from_response(data)
                item_search.total_results           = data['Items']['TotalResults'].to_i rescue 0
      Severity: Minor
      Found in lib/a2z/responses/item_search.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

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

                if data['HTTPHeaders'] && data['HTTPHeaders']['Header']
                  headers = array_wrap(data['HTTPHeaders']['Header'])
                  headers = headers.collect { |h| [ h['Name'], h['Value'] ] }
                  operation_request.headers = Hash[headers]
                end
      Severity: Minor
      Found in lib/a2z/responses/operation_request.rb and 1 other location - About 35 mins to fix
      lib/a2z/responses/operation_request.rb on lines 24..28

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

      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

                if data['Arguments'] && data['Arguments']['Argument']
                  arguments = array_wrap(data['Arguments']['Argument'])
                  arguments = arguments.collect { |a| [ a['Name'], a['Value'] ] }
                  operation_request.arguments = Hash[arguments]
                end
      Severity: Minor
      Found in lib/a2z/responses/operation_request.rb and 1 other location - About 35 mins to fix
      lib/a2z/responses/operation_request.rb on lines 18..22

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

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

            def self.from_response(data)
              new.tap do |item_lookup|
                item_lookup.operation_request = OperationRequest.from_response(data['OperationRequest']) if data['OperationRequest']
                item_lookup.item              = Item.from_response(data['Items']['Item']) if data['Items'] && data['Items']['Item']
                item_lookup.valid             = data['Items']['Request']['IsValid'] == 'True' rescue false
      Severity: Minor
      Found in lib/a2z/responses/item_lookup.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 from_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.from_response(data)
              new.tap do |operation_request|
                operation_request.request_id = data['RequestId']
                operation_request.request_processing_time = data['RequestProcessingTime'].to_f
                
      Severity: Minor
      Found in lib/a2z/responses/operation_request.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

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

                  if data['Children'] && data['Children']['BrowseNode']
                    children = array_wrap(data['Children']['BrowseNode'])
                    browse_node.children = children.collect { |child| BrowseNode.from_response(child) }
                  end
      Severity: Minor
      Found in lib/a2z/responses/browse_node.rb and 4 other locations - About 20 mins to fix
      lib/a2z/responses/browse_node.rb on lines 43..46
      lib/a2z/responses/item.rb on lines 62..65
      lib/a2z/responses/item.rb on lines 79..82
      lib/a2z/responses/item.rb on lines 84..87

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

      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 5 locations. Consider refactoring.
      Open

                if data['Offers'] && data['Offers']['Offer']
                  offers = array_wrap(data['Offers']['Offer'])
                  item.offers = offers.collect { |offer| Offer.from_response(offer) }
                end
      Severity: Minor
      Found in lib/a2z/responses/item.rb and 4 other locations - About 20 mins to fix
      lib/a2z/responses/browse_node.rb on lines 38..41
      lib/a2z/responses/browse_node.rb on lines 43..46
      lib/a2z/responses/item.rb on lines 62..65
      lib/a2z/responses/item.rb on lines 79..82

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

      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 5 locations. Consider refactoring.
      Open

                if data['ItemLinks'] && data['ItemLinks']['ItemLink']
                  item_links = array_wrap(data['ItemLinks']['ItemLink'])
                  item.links = item_links.collect { |link| ItemLink.from_response(link) }
                end
      Severity: Minor
      Found in lib/a2z/responses/item.rb and 4 other locations - About 20 mins to fix
      lib/a2z/responses/browse_node.rb on lines 38..41
      lib/a2z/responses/browse_node.rb on lines 43..46
      lib/a2z/responses/item.rb on lines 79..82
      lib/a2z/responses/item.rb on lines 84..87

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

      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 5 locations. Consider refactoring.
      Open

                if data['EditorialReviews'] && data['EditorialReviews']['EditorialReview']
                  reviews = array_wrap(data['EditorialReviews']['EditorialReview'])
                  item.editorial_reviews = reviews.collect { |review| EditorialReview.from_response(review) }
                end
      Severity: Minor
      Found in lib/a2z/responses/item.rb and 4 other locations - About 20 mins to fix
      lib/a2z/responses/browse_node.rb on lines 38..41
      lib/a2z/responses/browse_node.rb on lines 43..46
      lib/a2z/responses/item.rb on lines 62..65
      lib/a2z/responses/item.rb on lines 84..87

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

      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 5 locations. Consider refactoring.
      Open

                  if data['Ancestors'] && data['Ancestors']['BrowseNode']
                    ancestors = array_wrap(data['Ancestors']['BrowseNode'])
                    browse_node.ancestors = ancestors.collect { |ancestor| BrowseNode.from_response(ancestor) }
                  end
      Severity: Minor
      Found in lib/a2z/responses/browse_node.rb and 4 other locations - About 20 mins to fix
      lib/a2z/responses/browse_node.rb on lines 38..41
      lib/a2z/responses/item.rb on lines 62..65
      lib/a2z/responses/item.rb on lines 79..82
      lib/a2z/responses/item.rb on lines 84..87

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

      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 Responses
          class ItemLink
            attr_accessor :description, :url
            
            def self.from_response(data)
      Severity: Minor
      Found in lib/a2z/responses/item_link.rb and 1 other location - About 15 mins to fix
      lib/a2z/responses/editorial_review.rb on lines 2..10

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

      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 Responses
          class EditorialReview
            attr_accessor :source, :content
            
            def self.from_response(data)
      Severity: Minor
      Found in lib/a2z/responses/editorial_review.rb and 1 other location - About 15 mins to fix
      lib/a2z/responses/item_link.rb on lines 2..10

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

      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

      Severity
      Category
      Status
      Source
      Language