Showing 6 of 6 total issues
Class Base
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
attr_reader :model, :property, :options, :values, :default, :secondary_default
SUPPORTED_OPTIONS = [
Method define_humanized_value_instance_method
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def define_humanized_value_instance_method
restriction = self
multiple = @options[:multiple]
enhance_model do
define_method :"humanized_#{restriction.property.to_s.singularize}" do |*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
File base.rb
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
module AssignableValues
module ActiveRecord
module Restriction
class Base
Method assignable_values
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def assignable_values(record, options = {})
additional_assignable_values = []
current_values = assignable_values_from_record_or_delegate(record)
if options.fetch(:include_old_value, true) && has_previously_saved_value?(record)
- 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 set_default
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_default(record)
if record.new_record? && record.send(property).nil?
default_value = evaluate_default(record, default)
begin
if secondary_default? && !assignable_value?(record, default_value)
- 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 validate_record
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_record(record)
value = current_value(record)
unless allow_blank?(record) && value.blank?
begin
unless assignable_value?(record, value)
- 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"