Showing 22 of 35 total issues
Method index_fields
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index_fields
fields = {
ACCESS_ROLE => roles.to_json,
ADMIN_SET => admin_set,
ADMIN_SET_TITLE => admin_set_title,
Class PermanentId
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class PermanentId
class Error < Ddr::Models::Error; end
class AssignmentFailed < Error; end
class RepoObjectNotPersisted < Error; end
Class Structure
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Structure < SimpleDelegator
# Indicates whether the structure is externally provided or maintained by the repository itself (i.e., is the
# default structure for the object).
EXTERNALLY_PROVIDED = 'provided'.freeze
Class Base
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Base < ActiveFedora::Base
extend Deprecation
self.deprecation_horizon = 'ddr-models v3.0'
File solr_document.rb
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'json'
module Ddr::Models
module SolrDocument
extend ActiveSupport::Concern
Class Event
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ActiveRecord::Base
# ActiveSupport::Notifications::Instrumenter sets payload[:exception]
# to an array of [<exception class name>, <exception message>]
# and we want to store this data in a string field.
Method index_fields
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def index_fields
fields = {
ACCESS_ROLE => roles.to_json,
ADMIN_SET => admin_set,
ADMIN_SET_TITLE => admin_set_title,
- 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 update_derivatives
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def update_derivatives(schedule=SCHEDULE_LATER)
raise ArgumentError, "Must be one of #{SCHEDULES}" unless SCHEDULES.include?(schedule)
Ddr::Derivatives::DERIVATIVES.values.each do |derivative|
if Ddr::Derivatives.update_derivatives.include?(derivative.name)
# Need to update derivative if object has a datastream for this type of derivative and
- 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 pid_for_identifier
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.pid_for_identifier(identifier, opts={})
model = opts.fetch(:model, nil)
collection = opts.fetch(:collection, nil)
objs = []
ActiveFedora::Base.find_each( { Ddr::Index::Fields::IDENTIFIER_ALL => identifier }, { :cast => true } ) { |o| objs << o }
- 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 validate_checksum!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_checksum! checksum, checksum_type=nil
raise Ddr::Models::Error, "Checksum cannot be validated on new datastream." if new?
raise Ddr::Models::Error, "Checksum cannot be validated on unpersisted content." if content_changed?
raise Ddr::Models::ChecksumInvalid, "The repository internal checksum validation failed." unless dsChecksumValid
algorithm = checksum_type || self.checksumType
- 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 call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.call(file_or_path)
path = file_or_path.respond_to?(:path) ? file_or_path.path : file_or_path
# Use preferred media type, if available
media_type = Ddr::Models.preferred_media_types[(File.extname(path)).downcase]
if !media_type
- 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 desc_metadata_terms
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def desc_metadata_terms *args
return Ddr::Datastreams::DescriptiveMetadataDatastream.term_names if args.empty?
arg = args.pop
terms = case arg.to_sym
when :empty
Method call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.call(*args)
event = ActiveSupport::Notifications::Event.new(*args)
repo_id, identifier_id, reason = event.payload.values_at(:pid, :permanent_id, :reason)
case event.name
when Base::UPDATE
- 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 generate_derivative!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def generate_derivative!(derivative)
tempdir_path = File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname('',nil))
begin
tempdir = FileUtils.mkdir(tempdir_path).first
generator_source_path = source_datastream.external? ? source_datastream.file_path
- 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 desc_metadata_terms
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def desc_metadata_terms *args
return Ddr::Datastreams::DescriptiveMetadataDatastream.term_names if args.empty?
arg = args.pop
terms = case arg.to_sym
when :empty
- 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 dereferenced_hash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def dereferenced_hash
contents = []
contents.concat(divs.map { |div| div.dereferenced_hash }) unless divs.empty?
contents.concat(fptrs.map { |fptr| fptr.dereferenced_hash }) unless fptrs.empty?
contents.concat(mptrs.map { |mptr| mptr.dereferenced_hash }) unless mptrs.empty?
- 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 method_missing
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(name, *args, &block)
if args.empty? && !block
begin
field = Ddr::Index::Fields.get(name)
rescue NameError
- 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 user_groups
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def user_groups(user, raw = false)
groups = []
subject_id = user.principal_name.scan(SUBJECT_ID_RE).first
return groups unless subject_id
begin
- 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_file
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_file(file, dsid, mime_type: nil, external: false, original_filename: nil)
mime_type ||= MediaType.call(file) # XXX Should we use original_filename, if present?
source_path = Ddr::Utils.file_path(file)
original_filename ||= Ddr::Utils.file_name(file)
file_to_add = FileToAdd.new(dsid, source_path, original_filename)
- 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_use_to_structure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_use_to_structure(structure, filegrp, div, use, datastream_name)