Method to_citation
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def to_citation
citation = {}
# call self.metadata once and use the array for efficiency, don't
# keep calling it. profiling shows it DOES make a difference.
my_metadata = self.metadata
- 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_by_context_object
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def self.create_by_context_object(co, options = {})
self.clean_up_context_object(co)
rft = Referent.new
- 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
File referent.rb
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'i18n'
require 'truncate_to_db_limit'
# Note: There are a few actual attributes stored as Columns in referent --
# these were originally used for identifying a Referent identifying the
Method to_citation
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_citation
citation = {}
# call self.metadata once and use the array for efficiency, don't
# keep calling it. profiling shows it DOES make a difference.
my_metadata = self.metadata
Class Referent
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Referent < ActiveRecord::Base
# for shortcut metadata manipulations
include MetadataHelper
has_many :requests
Method enhance_referent
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def enhance_referent(key, value, metadata=true, private_data=false, options = {})
ActiveRecord::Base.connection_pool.with_connection do
return if value.nil?
- 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_by_context_object
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_by_context_object(co, options = {})
self.clean_up_context_object(co)
rft = Referent.new
Method enhance_referent
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def enhance_referent(key, value, metadata=true, private_data=false, options = {})
ActiveRecord::Base.connection_pool.with_connection do
return if value.nil?
Method clean_up_context_object
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.clean_up_context_object(co)
# First, remove any empty DOIs! or other empty identifiers?
# LOTS of sources send awful empty identifiers.
# That's not a valid identifier!
empty_ids = co.referent.identifiers.find_all { |i| i =~ Regexp.new('^[^:]+:[^/:]*(/|:)?$')}
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def enhance_referent(key, value, metadata=true, private_data=false, options = {})
Method set_values_from_context_object
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_values_from_context_object(co)
rft = co.referent
# Multiple identifiers are possible!
rft.identifiers.each do |id_string|
- 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"