Method get_collection
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_collection(model_config, scope, pagination)
section = @action.key == :export ? model_config.export : model_config.list
eager_loads = section.fields.flat_map(&:eager_load_values)
options = {}
options = options.merge(page: (params[Kaminari.config.param_name] || 1).to_i, per: (params[:per] || model_config.list.items_per_page)) if pagination
- 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 sanitize_params_for!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_params_for!(action, model_config = @model_config, target_params = params[@abstract_model.param_key])
return unless target_params.present?
fields = visible_fields(action, model_config)
allowed_methods = fields.collect(&:allowed_methods).flatten.uniq.collect(&:to_s) << 'id' << '_destroy'
- 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 action_missing
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def action_missing(name, *_args)
action = RailsAdmin::Config::Actions.find(name.to_sym)
raise AbstractController::ActionNotFound.new("The action '#{name}' could not be found for #{self.class.name}") unless action
get_model unless action.root?
- 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"