Showing 9 of 15 total issues
Class Entity
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Entity
# Internal accessors
attr_accessor :persisted, :session, :partial
class << self
Method fields
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fields
to_hash = Proc.new { |handle| handle.to_hash }
[
["Handle", :handle, Proc.new { |v| v.to_hash }],
["Id1", :id1],
Method fields
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fields
date_formatter = Proc.new { |date| date.respond_to?(:iso8601) ? date.iso8601 : nil }
to_hash = Proc.new { |handle| handle.to_hash }
[
["Id", :id, nil, :required],
Method fields
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fields
to_hash = Proc.new { |handle| handle.to_hash }
[
["Handle", :handle, to_hash, :required],
["Number", :handle, Proc.new { |h| h.number }, :required],
Method initialize_properties_with_values_from_owner
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize_properties_with_values_from_owner(invoice)
if owner.is_a?(Debtor)
invoice.debtor = owner
invoice.debtor_name ||= owner.name
- 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 verify_sanity_of_arguments!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def verify_sanity_of_arguments!(hash)
return if hash.is_a?(self.class)
if hash.nil? || (!hash.respond_to?(:to_i) && (!hash.respond_to?(:keys) && !hash.respond_to?(:values)))
raise ArgumentError.new("Expected Number, Hash or Economic::Entity::Handle - got #{hash.inspect}")
- 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 ==
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ==(other)
return true if self.object_id == other.object_id
return false if other.nil?
return false if empty? || (other.respond_to?(:empty?) && other.empty?)
return false unless other.respond_to?(:id) && other.respond_to?(:number)
- 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 to_hash
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_hash
data = {}
fields.each do |field, method, formatter, required|
value = entity.send(method)
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(hash)
verify_sanity_of_arguments!(hash)
hash = prepare_hash_argument(hash) unless hash.is_a?(self.class)
[:code, :name, :vat_code].each do |key|
- 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"