File marc_auth.rb
has 618 lines of code (exceeds 250 allowed). Consider refactoring. Open
class MARCAuthSerializer < ASpaceExport::Serializer
serializer_for :marc_auth
def serialize(marc, _opts = {})
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
Method controlfield_008
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
def controlfield_008(json, xml)
created_maint_events = json['agent_maintenance_histories'].select { |amh| amh['maintenance_event_type'] == 'created' }
pos0_5 = if created_maint_events.any?
created_maint_events.first['event_date'].strftime('%y%m%d')
else
Class MARCAuthSerializer
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class MARCAuthSerializer < ASpaceExport::Serializer
serializer_for :marc_auth
def serialize(marc, _opts = {})
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
Method controlfield_008
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def controlfield_008(json, xml)
created_maint_events = json['agent_maintenance_histories'].select { |amh| amh['maintenance_event_type'] == 'created' }
pos0_5 = if created_maint_events.any?
created_maint_events.first['event_date'].strftime('%y%m%d')
else
- 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 notes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def notes(json, xml)
with_value(json['notes'], 'jsonmodel_type', 'note_bioghist') do |note|
ind1 = agent_type(json) == :person || agent_type(json) == :family_name ? '0' : '1'
xml.datafield(tag: '678', ind1: ind1, ind2: ' ') do
with_value(note['subnotes'], 'jsonmodel_type', 'note_abstract') do |abstract|
- 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 _leader
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _leader(json, xml)
xml.leader do
if json['agent_record_controls']&.any?
arc = json['agent_record_controls'].first
Method relationships
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def relationships(json, xml)
json['related_agents'].each do |ra|
agent = ra['_resolved']
primary = agent['names'].select { |n| n['authorized'] == true }.first
# smuggle in the relator info. for this relationship
Method _marc
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _marc(obj, xml)
json = obj.json
xml.collection(
'xmlns' => 'https://www.loc.gov/MARC21/slim',
'xmlns:marc' => 'https://www.loc.gov/MARC21/slim',
Method _leader
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _leader(json, xml)
xml.leader do
if json['agent_record_controls']&.any?
arc = json['agent_record_controls'].first
- 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 relationships
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def relationships(json, xml)
json['related_agents'].each do |ra|
agent = ra['_resolved']
primary = agent['names'].select { |n| n['authorized'] == true }.first
# smuggle in the relator info. for this relationship
- 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 record_ids
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def record_ids(json, xml)
return unless json['agent_record_identifiers']&.any?
identifiers = json['agent_record_identifiers']
props = ['identifier_type']
Method names_person
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def names_person(primary, not_primary, parallel, xml)
# the primary name gets the 100 tag
if primary
ind1 = primary['name_order'] == 'indirect' ? '1' : '0'
xml.datafield(tag: '100', ind1: ind1, ind2: ' ') do
- 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 name_formatter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def name_formatter(parts, xml, omit_first_sub_prefix: false)
primary_subfield = parts.shift
subf(primary_subfield[:code], primary_subfield[:value], xml)
return unless parts.any? # jump ship if we don't have more parts
- 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 names_corporate_entity
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def names_corporate_entity(primary, not_primary, parallel, xml)
if primary
if primary['conference_meeting'] == true
xml.datafield(tag: '111', ind1: '2', ind2: ' ') do
corporate_name_subtags(primary, xml)
- 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 family_name_subtags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def family_name_subtags(name, xml, related = false)
related_sfs(name, xml) if related
name_parts = [
{ code: 'c', value: name['location'] },
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if n['conference_meeting'] == true
xml.datafield(tag: '411', ind1: '2', ind2: ' ') do
corporate_name_subtags(n, xml)
end
else
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 32.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if primary['conference_meeting'] == true
xml.datafield(tag: '111', ind1: '2', ind2: ' ') do
corporate_name_subtags(primary, xml)
end
else
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 32.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
with_value(identifiers, props, 'local') do |record|
xml.datafield(tag: '035', ind1: ' ', ind2: ' ') do
subf('a', record['record_identifier'], xml)
subf('2', record['source'], xml)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
case arc['cataloging_source']
when 'nat_bib_agency'
pos_39 = ' '
when 'ccp'
pos_39 = 'c'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
with_value(identifiers, props, 'lac') do |record|
xml.datafield(tag: '016', ind1: '7', ind2: ' ') do
subf('a', record['record_identifier'], xml)
subf('2', record['source'], xml)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
case place['place_role']
when 'place_of_birth'
subfield_code = 'a'
when 'place_of_death'
subfield_code = 'b'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76