File enju_manifestation.rb
has 487 lines of code (exceeds 250 allowed). Consider refactoring. Open
module EnjuLoc
module EnjuManifestation
extend ActiveSupport::Concern
included do
Method import_record_from_loc
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def self.import_record_from_loc(doc)
record_identifier = doc.at('//mods:recordInfo/mods:recordIdentifier', NS).try(:content)
identifier_type = IdentifierType.find_by(name: 'loc_identifier')
identifier_type ||= IdentifierType.create!(name: 'loc_identifier')
loc_identifier = Identifier.find_by(body: record_identifier, identifier_type_id: identifier_type.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
Method get_mods_carrier_and_content_types
has 133 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_mods_carrier_and_content_types(doc)
carrier_type = content_type = nil
doc.xpath('//mods:form', NS).each do |e|
authority = e.attributes['authority'].try(:content)
case authority
Method import_record_from_loc
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_record_from_loc(doc)
record_identifier = doc.at('//mods:recordInfo/mods:recordIdentifier', NS).try(:content)
identifier_type = IdentifierType.find_by(name: 'loc_identifier')
identifier_type ||= IdentifierType.create!(name: 'loc_identifier')
loc_identifier = Identifier.find_by(body: record_identifier, identifier_type_id: identifier_type.id)
Method get_mods_carrier_and_content_types
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mods_carrier_and_content_types(doc)
carrier_type = content_type = nil
doc.xpath('//mods:form', NS).each do |e|
authority = e.attributes['authority'].try(:content)
case authority
- 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 create_loc_subject_related_elements
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def self.create_loc_subject_related_elements(doc, manifestation)
subjects = get_mods_subjects(doc)
classifications = get_mods_classifications(doc)
if defined?(EnjuSubject)
subject_heading_type = SubjectHeadingType.find_by(name: 'lcsh') || SubjectHeadingType.create!(name: 'lcsh')
- 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 get_mods_titles
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mods_titles(doc)
original_title = ""
title_alternatives = []
doc.xpath('//mods:mods/mods:titleInfo', NS).each do |e|
type = e.attributes["type"].try(:content)
- 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 create_loc_series_statement
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.create_loc_series_statement(doc, manifestation)
doc.xpath('//mods:relatedItem[@type="series"]/mods:titleInfo/mods:title', NS).each do |series|
series_title = title = series.try(:content)
if title
series_title = title.split(';')[0].strip
- 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 get_mods_subjects
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mods_subjects(doc)
subjects = []
doc.xpath('//mods:subject[@authority="lcsh"]', NS).each do |s|
subject = []
s.xpath('./*', NS).each do |subelement|
- 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 get_mods_date_of_publication
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mods_date_of_publication(doc)
dates = []
doc.xpath('//mods:dateIssued', NS).each do |pub_date|
pub_date = pub_date.content.sub(/\A[cp]/, '')
next unless pub_date =~ /^\d+(-\d\d?){0,2}$/
- 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 get_mods_note
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mods_note(doc)
notes = []
doc.xpath('//mods:note', NS).each do |note|
type = note.attributes['type'].try(:content)
next if type == "statement of responsibility"
- 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 import_record_from_loc_isbn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.import_record_from_loc_isbn(options)
#if options[:isbn]
lisbn = Lisbn.new(options[:isbn])
raise EnjuLoc::InvalidIsbn unless lisbn.valid?
- 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 get_mods_extent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.get_mods_extent(doc)
extent = doc.at('//mods:extent', NS).try(:content)
value = {start_page: nil, end_page: nil, height: nil}
if extent
extent = extent.split(';')
- 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"