lib/frozen_record/scope.rb
Class Scope
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Scope
DISALLOWED_ARRAY_METHODS = [
:compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!,
:shuffle!, :slice!, :sort!, :sort_by!, :delete_if,
:keep_if, :pop, :shift, :delete_at, :compact
File scope.rb
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module FrozenRecord
class Scope
DISALLOWED_ARRAY_METHODS = [
:compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!,
:shuffle!, :slice!, :sort!, :sort_by!, :delete_if,
Method select_records
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def select_records(records)
return records if @where_values.empty? && @where_not_values.empty?
indices = @klass.index_definitions
indexed_where_values, unindexed_where_values = @where_values.partition { |criteria| indices.key?(criteria.first) }
Method select_records
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def select_records(records)
return records if @where_values.empty? && @where_not_values.empty?
indices = @klass.index_definitions
indexed_where_values, unindexed_where_values = @where_values.partition { |criteria| indices.key?(criteria.first) }
- 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 compare
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def compare(record_a, record_b)
@order_values.each do |attr, order|
a_value, b_value = record_a.send(attr), record_b.send(attr)
cmp = a_value <=> b_value
next if cmp == 0
- 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"