Showing 246 of 296 total issues
Method apply_constraints_to_record
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_constraints_to_record(record, options = {})
options[:allow_autosave] = false if options[:allow_autosave].nil?
constraints = options[:constraints] || active_scaffold_constraints
config = record.is_a?(active_scaffold_config.model) ? active_scaffold_config : active_scaffold_config_for(record.class)
Method add_to_js_app
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_to_js_app
original_js = File.binread(JS_APP)
if original_js.match?(/^import +['"]active_scaffold['"]/)
say_status('skipped', "append active_scaffold to #{JS_APP}", :yellow)
else
Method do_create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def do_create(options = {})
attributes = options[:attributes] || params[:record]
active_scaffold_config.model.transaction do
@record = new_model
# before assign params, to set foreign_type of constraints in polymorphic association with multiple 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_scaffold_record_select
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_record_select(record, column, options, value, multiple, ui_options: column.options)
unless column.association
raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). " \
'A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user).'
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 add_to_importmap
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_to_importmap
original_js = File.binread(IMPORTMAP)
if original_js.match?(/^pin +['"]active_scaffold['"](?=,|$)/)
say_status('skipped', "append active_scaffold to #{IMPORTMAP}", :yellow)
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 in_subform?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def in_subform?(column, parent_record, parent_column)
return true unless column.association
if column.association.reverse.nil?
# Polymorphic associations can't appear because they *might* be the reverse association
- 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 []
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def [](val)
links = []
@set.each do |item|
next if item == :separator
- 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 update_record_from_params
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_record_from_params(parent_record, columns, attributes, avoid_changes = false)
crud_type = parent_record.new_record? ? :create : :update
return parent_record unless parent_record.authorized_for?(crud_type: crud_type)
multi_parameter_attrs = multi_parameter_attributes(attributes)
- 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 add_link
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_link(attribute, options = {})
column = @core.columns[attribute.to_sym]
raise ArgumentError, "unknown column #{attribute}" if column.nil?
raise ArgumentError, "column #{attribute} is not an association" if column.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 columns_from_constraint
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def columns_from_constraint(column_name, value)
return if params_hash?(value)
if value.is_a?(Array)
column = active_scaffold_config.columns[column_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 add_query_string_to_cached_url
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_query_string_to_cached_url(link, url)
query_string, non_nested_query_string = query_string_for_action_links(link)
nested_params = !link.nested_link? && non_nested_query_string
if query_string || nested_params
url << (url.include?('?') ? '&' : '?')
- 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_defaults_for_column
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def setup_defaults_for_column
if active_record_class.respond_to?(:defined_enums) && active_record_class.defined_enums[name.to_s]
@form_ui = :select
@options = {options: active_record_class.send(name.to_s.pluralize).keys.map(&:to_sym)}
elsif 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
Function handleSaveEditor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSaveEditor: function(anEvent) {
if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
return;
var editor = this.dom.find('[name]:input:not(:button,[name=""])').not('input:checkbox:not(:checked)').not('input:radio:not(:checked)');
Method add_to_importmap
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_to_importmap
original_js = File.binread(IMPORTMAP)
if original_js.match?(/^pin +['"]active_scaffold['"](?=,|$)/)
say_status('skipped', "append active_scaffold to #{IMPORTMAP}", :yellow)
else
Method condition_for_search_ui
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def condition_for_search_ui(column, value, like_pattern, search_ui)
case search_ui
when :boolean, :checkbox
if value == 'null'
condition_for_null_type(column, value)
Method display_action_links
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def display_action_links(action_links, record, options, &block)
options[:level_0_tag] ||= nil
options[:options_level_0_tag] ||= nil
options[:level] ||= 0
options[:first_action] = true
Method active_scaffold_new_record_subform
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def active_scaffold_new_record_subform(column, record, html_options, ui_options: column.options, new_record_attributes: nil, locals: {}, skip_link: false)
klass =
if column.association.polymorphic? && column.association.belongs_to?
type = record.send(column.association.foreign_type)
column.association.klass(record) if type.present? && (ui_options[:add_new] == true || type.in?(ui_options[:add_new]))
Method updated_record_with_column
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def updated_record_with_column(column, value, scope)
record = params[:id] ? copy_attributes(find_if_allowed(params[:id], :read)) : new_model
apply_constraints_to_record(record) unless scope || params[:id]
create_association_with_parent record, check_match: true if nested?
if @form_action == :field_search && value.is_a?(Array) && column.association&.singular?
- 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_input_ancestry
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_input_ancestry(column, options, ui_options: column.options)
record = options[:object]
select_options = []
select_control_options = {selected: record.parent_id}
select_control_options[:include_blank] = as_(:_select_) if record.parent_id.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_field_for_update_columns
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render_field_for_update_columns
return if (@column = active_scaffold_config.columns[params.delete(:column)]).nil?
@columns = @column.update_columns || []
@columns << @column.name if @column.options[:refresh_link] && @columns.exclude?(@column.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"