team-umlaut/umlaut

View on GitHub
app/service_adaptors/google_book_search.rb

Summary

Maintainability
C
1 day
Test Coverage

File google_book_search.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class GoogleBookSearch < Service
  require 'multi_json'
  
  
  # Identifiers used in API response to indicate viewability level
Severity: Minor
Found in app/service_adaptors/google_book_search.rb - About 2 hrs to fix

    Method enhance_referent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def enhance_referent(request, data)
        
        entry = data["items"].first
        
    
    
    Severity: Minor
    Found in app/service_adaptors/google_book_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

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

      def handle(request)
    
        bibkeys = get_bibkeys(request.referent)
        return request.dispatched(self, true) if bibkeys.nil?
    
    
    Severity: Minor
    Found in app/service_adaptors/google_book_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

    Method do_web_links has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def do_web_links(request, data)
    
        # some noview items will have a snippet view, but we have no way to tell
        info_views = find_entries(data, ViewPartialValue)
        viewability = ViewPartialValue
    Severity: Minor
    Found in app/service_adaptors/google_book_search.rb - About 1 hr to fix

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

        def build_headers(request)
          original_forwarded_for = nil
          if (request.http_env && request.http_env['HTTP_X_FORWARDED_FOR'])
            original_forwarded_for = request.http_env['HTTP_X_FORWARDED_FOR']                                  
          end
      Severity: Minor
      Found in app/service_adaptors/google_book_search.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

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

        def service_types_generated
          types= []
      
          if @web_links
            types.push ServiceTypeValue[:highlighted_link]
      Severity: Minor
      Found in app/service_adaptors/google_book_search.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