team-umlaut/umlaut

View on GitHub
app/service_adaptors/internet_archive.rb

Summary

Maintainability
C
1 day
Test Coverage

File internet_archive.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class InternetArchive < Service
  require 'open-uri' #
  require 'cgi'
  require 'multi_json' #we ask IA for json
  require 'timeout' # used to timeout our requests
Severity: Minor
Found in app/service_adaptors/internet_archive.rb - About 4 hrs to fix

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

      def do_query(request)
        # get the search terms for use in both fulltext search and highlighted_link
        # IA does index apostrophes, although not generally other puncutation. Need to keep em.
        search_terms = {:title => get_search_title(request.referent ,:keep_apostrophes=>true),
        :creator => get_search_creator(request.referent)}
    Severity: Minor
    Found in app/service_adaptors/internet_archive.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 do_query has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def do_query(request)
        # get the search terms for use in both fulltext search and highlighted_link
        # IA does index apostrophes, although not generally other puncutation. Need to keep em.
        search_terms = {:title => get_search_title(request.referent ,:keep_apostrophes=>true),
        :creator => get_search_creator(request.referent)}
    Severity: Major
    Found in app/service_adaptors/internet_archive.rb - About 2 hrs to fix

      Method edition_str has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def edition_str(result)
          edition_str = ""
          
          edition_str << result['title'] unless result['title'].blank?
      
      
      Severity: Minor
      Found in app/service_adaptors/internet_archive.rb - About 55 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