lib/rails_admin/config/fields/base.rb
File base.rb
has 288 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'rails_admin/config/proxyable'
require 'rails_admin/config/configurable'
require 'rails_admin/config/hideable'
require 'rails_admin/config/groupable'
require 'rails_admin/config/inspectable'
Class Base
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Base # rubocop:disable Metrics/ClassLength
include RailsAdmin::Config::Proxyable
include RailsAdmin::Config::Configurable
include RailsAdmin::Config::Hideable
include RailsAdmin::Config::Groupable
Method sort_column
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def sort_column
if sortable == true
"#{abstract_model.quoted_table_name}.#{abstract_model.quote_column_name(name)}"
elsif (sortable.is_a?(String) || sortable.is_a?(Symbol)) && sortable.to_s.include?('.') # just provide sortable, don't do anything smart
sortable
- 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 optional
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def optional(state = nil, &block)
if !state.nil? || block
required state.nil? ? proc { instance_eval(&block) == false } : state == false
else
optional?
- 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"