Showing 246 of 296 total issues
Method update_column_association
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_column_association(parent_record, column, attribute, value, avoid_changes = false)
if avoid_changes
assign_column_association(parent_record, column, attribute, value)
elsif column.association.collection? && column.association.through_singular?
through = column.association.through_reflection.name
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(action, options = {})
# set defaults
@action = action
@label = action
@confirm = false
- 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
Avoid too many return
statements within this method. Open
return false unless association.source_reflection.collection? # create allowed if source is singular, rails creates joint model
Method display_message
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def display_message(message)
message = safe_join message, tag.br if message.is_a?(Array)
if (highlights = active_scaffold_config.user.highlight_messages)
message = highlights.inject(message) do |msg, (phrases, highlighter)|
highlight(msg, phrases, highlighter || {})
- 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_radio_option
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_radio_option(option, selected, column, radio_options, ui_options: column.options)
if column.association
label_method = ui_options[:label_method] || :to_label
text = option.send(label_method)
value = option.id
- 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_record_column_type_cast
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.active_record_column_type_cast(value, column_or_type)
return Time.zone.at(value.to_i) if %i[time datetime].include?(column_or_type.type) && value =~ /\A\d+\z/
cast_type = column_or_type.is_a?(ActiveRecord::ConnectionAdapters::Column) ? ActiveRecord::Type.lookup(column_or_type.type) : column_or_type
cast_type ? cast_type.cast(value) : 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 create_respond_to_js
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_respond_to_js
if successful? && !render_parent?
do_refresh_list if active_scaffold_config.create.refresh_list
if params[:dont_close]
@saved_record = @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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def call(mapper, options = {})
actions = get_actions(ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING, options)
mapper.collection do
ActiveScaffold::Routing::ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING[:collection].each do |name, type|
- 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_checkbox_option
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_checkbox_option(option, label_method, associated_ids, checkbox_options, li_options = {})
content_tag(:li, li_options) do
option_id = option.is_a?(Array) ? option[1] : option.id
label = option.is_a?(Array) ? option[0] : option.send(label_method)
check_box_tag(checkbox_options[:name], option_id, associated_ids.include?(option_id), checkbox_options) <<
- 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_add_existing_input
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_add_existing_input(options)
record = options.delete(:object)
if controller.respond_to?(:record_select_config, true)
remote_controller = active_scaffold_controller_for(record_select_config.model).controller_path
options[:controller] = remote_controller
- 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_jquery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_jquery(file, original_js = nil, where: 'ujs')
original_js ||= File.binread(file)
if Object.const_defined?(:Jquery)
unless original_js.include?('require jquery')
insert_into_file file, before: %r{//= require +.*#{where}['"]?\n} 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
Method format_to_datetime_picker
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.format_to_datetime_picker(rails_time_format)
date_format, time_format = split_datetime_format(to_datepicker_format(rails_time_format))
datetime_picker_options = {}
datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
unless time_format.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 field_search_record_select_value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def field_search_record_select_value(column, value, ui_options: column.options)
return if value.blank?
if ui_options[:multiple]
column.association.klass.find value.compact_blank.collect!(&:to_i)
- 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_nested
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def configure_nested
return unless nested?
register_constraints_with_action_columns(nested.constrained_fields)
return unless active_scaffold_config.actions.include? :list
- 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_tab_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_tab_options(column, record)
subform_column = column.first
if subform_column
tabbed_by = subform_column.options[:tabbed_by] || column.tabbed_by
if tabbed_by_association(subform_column, tabbed_by)
- 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_hidden_field
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def form_hidden_field(column, record, scope)
options = active_scaffold_input_options(column, scope)
if column.association&.collection?
associated = record.send(column.name)
if associated.blank?
- 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 init_field_search_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def init_field_search_params(default_params)
return unless (params[:search].is_a?(String) || search_params.nil?) && params[:search].blank?
params[:search] = default_params.is_a?(Proc) ? instance_eval(&default_params) : default_params
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 datepicker_format_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def datepicker_format_options(column, format)
return {} if format == :default
if column.form_ui == :date_picker
js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
- 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_search_multi_select
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_search_multi_select(column, options, ui_options: column.options)
record = options.delete(:object)
associated = options.delete :value
associated = [associated].compact unless associated.is_a? Array
- 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_method
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_column_method(record, column)
# check for an override helper
ActiveScaffold::Registry.cache :column_methods, column.cache_key do
if (method = column_override(column))
# we only pass the record as the argument. we previously also passed the formatted_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"