Showing 72 of 107 total issues
Method ordered_filters
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def ordered_filters
return @ordered_filters if @ordered_filters.present?
@index = 0
@ordered_filters = (params[:f].try(:permit!).try(:to_h) || @model_config.list.filters).inject({}) do |memo, filter|
- 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 generic_help
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def generic_help
text = "#{required? ? I18n.translate('admin.form.required') : I18n.translate('admin.form.optional')}. "
if valid_length.present? && valid_length[:is].present?
text += "#{I18n.translate('admin.form.char_length_of').capitalize} #{valid_length[:is]}."
else
- 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 register_instance_option
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def register_instance_option(option_name, scope = self, &default)
options = scope.instance_variable_get('@config_options') ||
scope.instance_variable_set('@config_options', {})
option_name = option_name.to_s
- 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 listing_for_model_or_object
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
sort =
if sort.present?
{COLUMN_MAPPING[sort.to_sym] => sort_reverse ? :desc : :asc}
else
- 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 field
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def field(name, type = nil, add_to_section = true, &block)
field = _fields.detect { |f| name == f.name }
# some fields are hidden by default (belongs_to keys, has_many associations in list views.)
# unhide them if config specifically defines them
- 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 symbolize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.symbolize(obj)
case obj
when Array
obj.each_with_object([]) do |val, res|
res << case val
- 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
Function _query
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
_query: function (query, success) {
var i,
matches = [];
if (query === "") {
Function _getResultSet
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getResultSet: function (request, data, xhr) {
var matcher = new RegExp(
$.ui.autocomplete.escapeRegex(request.term),
"i"
);
Method navigation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def navigation(parent_groups, nodes, level = 0)
nodes.collect do |node|
abstract_model = node.abstract_model
model_param = abstract_model.to_param
url = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
- 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 filter_scope
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def filter_scope(scope, filters, fields = config.list.fields.select(&:filterable?))
statements = []
filters.each_pair do |field_name, filters_dump|
filters_dump.each_value do |filter_dump|
- 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
Function _create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_create: function () {
var widget = this;
var dom_widget = widget.element;
var edit_url =
Function _getModal
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getModal: function () {
var widget = this;
if (!widget.dialog) {
widget.dialog = $(
'<div id="modal" class="modal fade">\
Method fields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def fields(*field_names, &block)
return all_fields if field_names.empty? && !block
if field_names.empty?
defined = _fields.select(&:defined)
- 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 build_statement_for_string_or_text
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def build_statement_for_string_or_text
return if @value.blank?
return ["(#{@column} = ?)", @value] if ['is', '='].include?(@operator)
- 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 field_wrapper_for
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def field_wrapper_for(field, nested_in)
# do not show nested field if the target is the origin
return if nested_field_association?(field, nested_in)
@template.content_tag(:div, class: "control-group row mb-3 #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do
- 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
Function _move
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_move: function (direction, options) {
var widget = this;
if (direction == "up") {
options.each(function (i, option) {
var prev = $(option).prev();
Function _getSourceFunction
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getSourceFunction: function (source) {
var self = this;
var requestIndex = 0;
if ($.isArray(source)) {
Method reset
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset
@compact_show_view = true
@browser_validations = true
@authenticate = nil
@authorize = nil
Function _create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_create: function () {
this.filtering_select = this.element.siblings(
'[data-input-for="' + this.element.attr("id") + '"]'
);
Method add
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add(field, value, operator)
field.searchable_columns.flatten.each do |column_infos|
statement, value1, value2 = StatementBuilder.new(column_infos[:column], column_infos[:type], value, operator, @scope.connection.adapter_name).to_statement
@statements << statement if statement.present?
@values << value1 unless value1.nil?
- 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"