app/service_adaptors/internet_archive.rb
File internet_archive.rb
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class InternetArchive < Service
require 'open-uri' #
require 'cgi'
require 'multi_json' #we ask IA for json
require 'timeout' # used to timeout our requests
Method do_query
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
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)}
- Read upRead up
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
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)}
Method edition_str
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def edition_str(result)
edition_str = ""
edition_str << result['title'] unless result['title'].blank?
- Read upRead up
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"