Showing 91 of 115 total issues
Class Collection
has 79 methods (exceeds 20 allowed). Consider refactoring.
class Collection < LazyArray
# Returns the Query the Collection is scoped with
#
# @return [Query]
File query.rb
has 620 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
# Query class represents a query which will be run against the data-store.
# Generally Query objects can be found inside Collection objects.
#
Class Query
has 68 methods (exceeds 20 allowed). Consider refactoring.
class Query
include DataMapper::Assertions
extend Equalizer
OPTIONS = [ :fields, :links, :conditions, :offset, :limit, :order, :unique, :add_reversed, :reload ].to_set.freeze
File collection.rb
has 529 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
# The Collection class represents a list of resources persisted in
# a repository and identified by a query.
#
# A Collection should act like an Array in every way, except that
File resource.rb
has 461 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
module Resource
include DataMapper::Assertions
# Return if Resource#save should raise an exception on save failures (per-resource)
Class LazyArray
has 43 methods (exceeds 20 allowed). Consider refactoring.
class LazyArray # borrowed partially from StrokeDB
include Enumerable
attr_reader :head, :tail
Class Relationship
has 40 methods (exceeds 20 allowed). Consider refactoring.
class Relationship
include DataMapper::Assertions
include Subject
OPTIONS = [ :child_repository_name, :parent_repository_name, :child_key, :parent_key, :min, :max, :inverse, :reader_visibility, :writer_visibility, :default ].to_set
Method load
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
def load(records, query)
repository = query.repository
repository_name = repository.name
fields = query.fields
discriminator = properties(repository_name).discriminator
- 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
Class Property
has 38 methods (exceeds 20 allowed). Consider refactoring.
class Property
include DataMapper::Assertions
include Subject
extend Equalizer
File comparison.rb
has 364 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
class Query
# The Conditions module contains classes used as part of a Query when
# filtering collections of resources.
#
File lazy_array.rb
has 361 lines of code (exceeds 250 allowed). Consider refactoring.
class LazyArray # borrowed partially from StrokeDB
include Enumerable
attr_reader :head, :tail
File model.rb
has 348 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
module Model
include Enumerable
WRITER_METHOD_REGEXP = /=\z/.freeze
Method assert_valid_options
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
def assert_valid_options(options)
keys = options.keys
if (unknown_keys = keys - self.class.accepted_options).any?
raise ArgumentError, "options #{unknown_keys.map { |key| key.inspect }.join(' and ')} are unknown"
- 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
Class PropertySet
has 27 methods (exceeds 20 allowed). Consider refactoring.
class PropertySet < SubjectSet
include Enumerable
def <<(property)
clear_cache
File relationship.rb
has 296 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
module Associations
# Base class for relationships. Each type of relationship
# (1 to 1, 1 to n, n to m) implements a subclass of this class
# with methods like get and set overridden.
Method assert_valid_options
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
def assert_valid_options(options)
# TODO: update to match Query#assert_valid_options
# - perform options normalization elsewhere
if options.key?(:min) && options.key?(:max)
- 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
Class AbstractOperation
has 26 methods (exceeds 20 allowed). Consider refactoring.
class AbstractOperation
include DataMapper::Assertions
include Enumerable
extend Equalizer
File many_to_many.rb
has 286 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
module Associations
module ManyToMany #:nodoc:
class Relationship < Associations::OneToMany::Relationship
extend Chainable
Method nested_const_lookup
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
def self.nested_const_lookup(mod, const_name)
unless mod.equal?(::Object)
constants = []
mod.name.split('::').each do |part|
- 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
Class AbstractComparison
has 23 methods (exceeds 20 allowed). Consider refactoring.
class AbstractComparison
extend Equalizer
equalize :subject, :value
File property.rb
has 269 lines of code (exceeds 250 allowed). Consider refactoring.
module DataMapper
# = Properties
# Properties for a model are not derived from a database structure, but
# instead explicitly declared inside your model class definitions. These
# properties then map (or, if using automigrate, generate) fields in your
Method install_hook
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def install_hook(type, target_method, method_sym, scope, &block)
assert_kind_of 'target_method', target_method, Symbol
assert_kind_of 'method_sym', method_sym, Symbol unless method_sym.nil?
assert_kind_of 'scope', scope, Symbol
- 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
Class Relationship
has 22 methods (exceeds 20 allowed). Consider refactoring.
class Relationship < Associations::Relationship
OPTIONS = superclass::OPTIONS.dup << :required << :key << :unique
# @api semipublic
alias_method :source_repository_name, :child_repository_name
Method target_conditions
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
def self.target_conditions(source, source_key, target_key)
target_key_size = target_key.size
source_values = []
if source.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
Class Relationship
has 21 methods (exceeds 20 allowed). Consider refactoring.
class Relationship < Associations::OneToMany::Relationship
extend Chainable
OPTIONS = superclass::OPTIONS.dup << :through << :via
Method assert_valid_conditions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def assert_valid_conditions(conditions)
case conditions
when Hash
conditions.each do |subject, bind_value|
case subject
- 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 default_attributes
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def default_attributes
return @default_attributes if @default_attributes
default_attributes = {}
- 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 last
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def last(*args)
first_arg = args.first
last_arg = args.last
limit_specified = first_arg.kind_of?(Integer)
- 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 install_hook
has 49 lines of code (exceeds 25 allowed). Consider refactoring.
def install_hook(type, target_method, method_sym, scope, &block)
assert_kind_of 'target_method', target_method, Symbol
assert_kind_of 'method_sym', method_sym, Symbol unless method_sym.nil?
assert_kind_of 'scope', scope, Symbol
Method load
has 49 lines of code (exceeds 25 allowed). Consider refactoring.
def load(records, query)
repository = query.repository
repository_name = repository.name
fields = query.fields
discriminator = properties(repository_name).discriminator
Method first
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
def first(*args)
first_arg = args.first
last_arg = args.last
limit_specified = first_arg.kind_of?(Integer)
- 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 _save
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
def _save(execute_hooks = true)
via = self.via
if @removed.any?
# delete only intermediaries linked to the removed targets
- 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 assert_valid_options
has 39 lines of code (exceeds 25 allowed). Consider refactoring.
def assert_valid_options(options)
# TODO: update to match Query#assert_valid_options
# - perform options normalization elsewhere
if options.key?(:min) && options.key?(:max)
Method scoped_query
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def scoped_query(query)
if query.kind_of?(Query)
query.dup
else
repository = if query.key?(:repository)
- 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 assert_valid_options
has 35 lines of code (exceeds 25 allowed). Consider refactoring.
def assert_valid_options(options)
keys = options.keys
if (unknown_keys = keys - self.class.accepted_options).any?
raise ArgumentError, "options #{unknown_keys.map { |key| key.inspect }.join(' and ')} are unknown"
Consider simplifying this complex logical expression.
if other_query.links.empty? &&
(unique || (!unique && !query.unique?)) &&
!other_query.reload? &&
!other_query.raw? &&
other_query.fields.to_set.subset?(fields) &&
Method target_conditions
has 32 lines of code (exceeds 25 allowed). Consider refactoring.
def self.target_conditions(source, source_key, target_key)
target_key_size = target_key.size
source_values = []
if source.nil?
Method initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def initialize(model, name, options = {})
super
if kind_of?(Decimal) || kind_of?(Float)
@precision = @options.fetch(:precision)
- 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 property
has 30 lines of code (exceeds 25 allowed). Consider refactoring.
def property(name, type, options = {})
# if the type can be found within Property then
# use that class rather than the primitive
klass = DataMapper::Property.determine_class(type)
Method property
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def property(name, type, options = {})
# if the type can be found within Property then
# use that class rather than the primitive
klass = DataMapper::Property.determine_class(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 extract_slice_arguments
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def extract_slice_arguments(*args)
first_arg, second_arg = args
if args.size == 2 && first_arg.kind_of?(Integer) && second_arg.kind_of?(Integer)
return first_arg, second_arg
- 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 cmp?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def cmp?(other, operator)
unless loaded?
# compare the head against the beginning of other. start at index
# 0 and incrementally compare each entry. if other is a LazyArray
# this has a lesser likelyhood of triggering a lazy load
- 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 new
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
def self.new(repository_name, options)
options = normalize_options(options)
case options.fetch(:adapter)
when 'java'
Method initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
def initialize(model, name, options = {})
options = options.to_hash.dup
if INVALID_NAMES.include?(name.to_s) || (kind_of?(Boolean) && INVALID_NAMES.include?("#{name}?"))
raise ArgumentError,
Method has
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
def has(cardinality, name, *args)
name = name.to_sym
model = extract_model(args)
options = extract_options(args)
Method lazy_load
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def lazy_load(source)
source_key_different = source_key_different?(source)
if (loaded?(source) && !source_key_different) || !valid_source?(source)
return
- 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 parent_relationships
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def parent_relationships
parent_relationships = []
relationships.each do |relationship|
next unless relationship.respond_to?(:resource_for)
- 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 attributes=
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def attributes=(attributes)
model = self.model
attributes.each do |name, value|
case name
when String, Symbol
- 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 inline_call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def inline_call(method_info, scope)
DataMapper::Hook::ClassMethods.hook_scopes << method_info[:from]
name = method_info[:name]
if scope == :instance
args = method_defined?(name) && instance_method(name).arity != 0 ? '*args' : ''
- 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 first
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def first(*args)
first_arg = args.first
last_arg = args.last
limit_specified = first_arg.kind_of?(Integer)
- 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"