team-umlaut/umlaut

View on GitHub
app/service_adaptors/amazon.rb

Summary

Maintainability
D
1 day
Test Coverage

Method add_aws_service_responses has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def add_aws_service_responses(request, aws_response)
    return_hash = Hash.new
        
    aws = Nokogiri::XML(aws_response.body)
    # extract and collect info from the xml    
Severity: Minor
Found in app/service_adaptors/amazon.rb - About 5 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 add_aws_service_responses has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_aws_service_responses(request, aws_response)
    return_hash = Hash.new
        
    aws = Nokogiri::XML(aws_response.body)
    # extract and collect info from the xml    
Severity: Major
Found in app/service_adaptors/amazon.rb - About 3 hrs to fix

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

      def add_asin_service_responses(request, asin, item_url)
        # we want to highlight Amazon to link to 'search in this book', etc.
        if asin
          # Search or Look inside the book offered? We only know by trying and
          # then screen-scraping.
    Severity: Minor
    Found in app/service_adaptors/amazon.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 add_asin_service_responses has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def add_asin_service_responses(request, asin, item_url)
        # we want to highlight Amazon to link to 'search in this book', etc.
        if asin
          # Search or Look inside the book offered? We only know by trying and
          # then screen-scraping.
    Severity: Major
    Found in app/service_adaptors/amazon.rb - About 2 hrs to fix

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

        def handle(request)
          
          isbn = request.referent.metadata['isbn']
          isbn = isbn.gsub(/[^0-9X]/,'') if isbn
          
      Severity: Minor
      Found in app/service_adaptors/amazon.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

      Avoid too many return statements within this method.
      Open

          return request.dispatched(self, true)
      Severity: Major
      Found in app/service_adaptors/amazon.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return request.dispatched(self, DispatchedService::FailedFatal, e)
        Severity: Major
        Found in app/service_adaptors/amazon.rb - About 30 mins to fix

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

            def initialize(config)
              # defaults
              @url = 'http://webservices.amazon.com/onca/xml'     
              @reader_base_url = 'http://www.amazon.com/gp/reader/'
              @display_name = "Amazon.com"
          Severity: Minor
          Found in app/service_adaptors/amazon.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