Method handle
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def handle(request)
search = search(request)
return request.dispatched(self, true) if search.nil?
records = search.records
if records.blank? && /^dedupmrg/ === @record_id
- 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
Class PrimoService
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class PrimoService < Service
required_config_params :base_url, :vid, :institution
# For matching purposes.
attr_reader :title, :author
File primo_service.rb
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'exlibris-primo'
class PrimoService < Service
required_config_params :base_url, :vid, :institution
# For matching purposes.
Method add_link_services
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def add_link_services(request, links, service_type, suppress_links, &block)
links_seen = [] # for de-duplicating urls
links.each do |link|
next if links_seen.include?(link.url)
# Check the list of URLs to suppress, array of strings or regexps.
- 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 add_holding_services
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def add_holding_services(request, holdings)
holdings.each do |holding|
next if @suppress_holdings.find {|suppress_holding| suppress_holding === holding.availlibrary}
service_data = {}
# Availability status from Primo is probably out of date, so set to "check_holdings"
- 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 handle
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle(request)
search = search(request)
return request.dispatched(self, true) if search.nil?
records = search.records
if records.blank? && /^dedupmrg/ === @record_id
Method reliable_match?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def reliable_match?(record_metadata)
return true unless (@record_id.nil? or @record_id.empty?)
return true unless (@issn.nil? or @issn.empty?) and (@isbn.nil? or @isbn.empty?)
return false if (record_metadata.nil? or record_metadata.empty? or record_metadata[:title].nil? or record_metadata[:title].empty?)
# Titles must be equal
- 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 initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(config)
@holding_search_text = "Search for this title."
# Configure Primo
configure_primo
# Attributes for holding service data.
Method search
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def search(request, skip_id = false)
# Get the possible search params
@identifier = request.referrer_id
@record_id = record_id(request) unless skip_id
@isbn = isbn(request)
- 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 enhance_referent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def enhance_referent(request, record)
@referent_enhancements.each do |key, options|
metadata_element = (options[:value].nil?) ? key : options[:value]
# Enhance the referent from the 'addata' section
metadata_method = "addata_#{metadata_element}".to_sym
- 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 add_link_services
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_link_services(request, links, service_type, suppress_links, &block)
Avoid too many return
statements within this method. Open
return false unless record_metadata[:author].to_s.downcase.eql?(@author.downcase)
Avoid too many return
statements within this method. Open
return true
Method backward_compatibility
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def backward_compatibility(config)
# For backward compatibility, re-map "old" config values to new more
# Umlaut-y names and print deprecation warning in the logs.
old_to_new_mappings = {
:base_path => :base_url,
- 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"