Class Property
has 38 methods (exceeds 20 allowed). Consider refactoring.
class Property
include DataMapper::Assertions
include Subject
extend Equalizer
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
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 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"
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,
Consider simplifying this complex logical expression.
if required? && dumped_value.nil?
negated || false
else
value_dumped?(dumped_value) || (dumped_value.nil? && (allow_nil? || negated))
end
Method initialize
has a Cognitive Complexity of 7 (exceeds 5 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,
- 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 valid?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def valid?(value, negated = false)
dumped_value = dump(value)
if required? && dumped_value.nil?
negated || false
- 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"