Showing 246 of 296 total issues
Function update_column
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
update_column: function(element, url, send_form, source_id, val, additional_params) {
if (!element) element = jQuery('#' + source_id);
var as_form = element.closest('form.as_form');
var params = null;
File list.rb
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ActiveScaffold::Actions
module List
def self.included(base)
base.before_action :list_authorized_filter, only: :index
base.helper_method :list_columns, :count_on_association_class?
Method update_columns_options
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def update_columns_options(column, scope, options, force = false, form_columns: nil, url_params: {})
record = options[:object]
subform_controller = controller.class.active_scaffold_controller_for(record.class) if scope
if @main_columns && (scope.nil? || subform_controller == controller.class)
form_columns ||= @main_columns.visible_columns_names
- 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 form_attribute
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def form_attribute(column, record, scope = nil, only_value = false, col_class = nil)
column_options = active_scaffold_input_options(column, scope, object: record)
collapsible_id = column_options.delete :collapsible_id
attributes = field_attributes(column, record)
attributes[:class] = "#{attributes[:class]} #{col_class}" if col_class.present?
- 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 active_scaffold_error_messages_for
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def active_scaffold_error_messages_for(*params)
options = params.extract_options!.symbolize_keys
options.reverse_merge!(container_tag: :div, list_type: :ul)
objects = Array.wrap(options.delete(:object) || params).map do |object|
Method column_class
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def column_class(column, column_value, record)
classes = ActiveScaffold::Registry.cache :column_classes, column.cache_key do
classes = "#{column.name}-column "
classes << 'sorted ' if active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.user.sorting.sorts_on?(column)
classes << 'numeric ' if column.number?
- 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_link_url_options
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def action_link_url_options(link, record)
url_options = {action: link.action}
url_options[:id] = '--ID--' unless record.nil?
url_options[:controller] = link.controller.to_s if link.controller
url_options.merge! link.parameters if link.parameters
- 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 query_string_for_action_links
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def query_string_for_action_links(link)
if defined?(@query_string) && link.parameters.none? { |k, _| @query_string_params.include? k }
return [@query_string, @non_nested_query_string]
end
- 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 columns_reader
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.columns_reader(name, options, &block)
var = :"@#{name}"
define_method name do
unless instance_variable_defined?(var) # lazy evaluation
action, columns = options[:copy] if options[:copy]
- 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 sorting
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def sorting
if @_sorting.nil?
# we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
self['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] && @params['sort_direction']
self['sort'] = nil if @params['sort_direction'] == 'reset'
- 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 pagination_ajax_links
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pagination_ajax_links(current_page, url_options, options, inner_window, outer_window)
start_number = current_page.number - inner_window
end_number = current_page.number + inner_window
start_number = 1 if start_number <= 0
if current_page.pager.infinite?
Method authorized_for?
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def authorized_for?(options = {})
raise InvalidArgument if options[:crud_type].blank? && options[:action].blank?
if current_ability.present?
crud_type_result = options[:crud_type].nil? ? true : current_ability.can?(options[:crud_type], self)
- 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 get_column_value
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_column_value(record, column)
record = record.send(column.delegated_association.name) if column.delegated_association
if record
method, list_ui = get_column_method(record, column)
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 setup_parent
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def setup_parent(record)
cfg = main_form_controller.active_scaffold_config
association = cfg.columns[subform_child_association]&.association&.reverse_association
return if association.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"
Further reading
Method render_list_column
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def render_list_column(text, column, record)
if column.link && !skip_action_link?(column.link, record)
link = column.link
associated = record.send(column.association.name) if column.association
authorized = link.action.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"
Further reading
Method configure_column_link
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def configure_column_link(link, record, associated, actions = nil)
actions ||= link.controller_actions || []
if column_empty?(associated) # if association is empty, we only can link to create form
if actions.include?(:new)
link.action = 'new'
- 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 conditions_from_constraints
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def conditions_from_constraints
hash_conditions = {}
conditions = [hash_conditions]
active_scaffold_constraints.each do |k, v|
column = active_scaffold_config.columns[k]
- 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 condition_from_association_constraint
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def condition_from_association_constraint(association, value)
# when the reverse association is a :belongs_to, the id for the associated object only exists as
# the primary_key on the other table. so for :has_one and :has_many (when the reverse is :belongs_to),
# we have to use the other model's primary_key.
#
- 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 initialize
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def initialize(name, active_record_class, delegated_association = nil) # :nodoc:
@name = name.to_sym
@active_record_class = active_record_class
@column = _columns_hash[name.to_s]
if @column.nil? && active_record? && active_record_class._default_attributes.key?(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 condition_value_for_datetime
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def condition_value_for_datetime(column, value, conversion = :to_time, ui_method: :search_ui, ui_options: nil)
return if value.nil? || value.blank?
ui_options ||= column.send(:"#{ui_method}_options") || column.options
if value.is_a? Hash
- 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"