File trackable.rb
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Mongoid
module History
module Trackable
extend ActiveSupport::Concern
Method related_scope
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def related_scope
scope = history_trackable_options[:scope]
# Use top level document if its name is specified in the scope
root_document_name = traverse_association_chain.first['name'].singularize.underscore.tr('/', '_').to_sym
- 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 get_versions_criteria
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_versions_criteria(options_or_version)
if options_or_version.is_a? Hash
options = options_or_version
if options[:from] && options[:to]
lower = options[:from] >= options[:to] ? options[:to] : options[:from]
- 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 track_history
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def track_history(options = {})
extend RelationMethods
history_options = Mongoid::History::Options.new(self, options)
- 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 association_hash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def association_hash(node = self)
# We prefer to look up associations through the parent record because
# we're assured, through the object creation, it'll exist. Whereas we're not guaranteed
# the child to parent (embedded_in, belongs_to) relation will be defined
if node._parent
- 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
Avoid deeply nested control flow statements. Open
scope = _association.inverse_class_name.tableize.singularize.to_sym if _association.present? && scope == _association.as
Method track_history_for_action
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def track_history_for_action(action)
if track_history_for_action?(action)
current_version = increment_current_version?(action) ? increment_current_version : next_version
last_track = self.class.tracker_class.create!(
history_tracker_attributes(action.to_sym)
- 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 transform_changes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def transform_changes(changes)
original = {}
modified = {}
changes.each_pair do |k, modification_pair|
o, m = modification_pair
- 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"