File hash_converter.rb
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RelatonBib
module HashConverter
extend self
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
Method contributors_hash_to_bib
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def contributors_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
return unless ret[:contributor]
ret[:contributor] = RelatonBib.array(ret[:contributor])
ret[:contributor]&.each_with_index do |c, i|
- 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 hash_to_bib
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def hash_to_bib(args)
return nil unless args.is_a?(Hash)
ret = Marshal.load(Marshal.dump(symbolize(args))) # deep copy
title_hash_to_bib(ret)
Method series_hash_to_bib
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def series_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
ret[:series] = RelatonBib.array(ret[:series])&.map do |s|
s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
if s[:title]
s[:title] = { content: s[:title] } unless s[:title].is_a?(Hash)
- 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 affiliation_hash_to_bib
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def affiliation_hash_to_bib(person) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
return [] unless person[:affiliation]
RelatonBib.array(person[:affiliation]).map do |a|
a[:description] = RelatonBib.array(a[:description]).map do |d|
- 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"