Showing 296 of 296 total issues
Method active_scaffold_render_subform_column
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def active_scaffold_render_subform_column(column, scope, crud_type, readonly, add_class = false, record = nil) # rubocop:disable Metrics/ParameterLists
Method render_embedded
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def render_embedded(options)
require 'digest/md5'
remote_controller = options[:active_scaffold]
# It is important that the EID hash remains short as to not contribute
- 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_datetime_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_search_datetime_field(column, options, current_search, name, ui_options: column.options)
options = ui_options.merge(options)
type = "#{'date' unless options[:discard_date]}#{'time' unless options[:discard_time]}"
field_name = "#{options[:name]}[#{name}]"
if options[:use_select]
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(model_id)
super
return unless ActiveScaffold::Bridges::DatePicker.default_ui
types = %i[date datetime timestamp timestamptz]
- 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 with_unsaved_associated
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def with_unsaved_associated(&block)
associations_for_update.map do |assoc|
association_proxy = association(assoc.name)
if association_proxy.target.present?
records = association_proxy.target
- 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_file_with_remove_link
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def active_scaffold_file_with_remove_link(column, options, content, remove_file_prefix, controls_class, ui_options: column.options, &block)
Function update_column
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
update_column: function(element, url, send_form, source_id, val, additional_params) {
Method column_heading_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def column_heading_value(column, sorting, sort_direction)
if column.name == :as_marked
mark_column_heading
elsif column.sortable?
options = {id: nil, class: 'as_sort',
- 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 responds_to_parent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def responds_to_parent(&block)
yield
return unless performed?
# Either pull out a redirect or the request body
- 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_refresh_link
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def active_scaffold_refresh_link(column, html_options, record, ui_options = {})
link_options = {object: record}
if html_options['data-update_url']
link_options['data-update_send_form'] = html_options['data-update_send_form']
link_options['data-update_send_form_selector'] = html_options['data-update_send_form_selector']
- 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_for_datetime
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def format_for_datetime(column, value, ui_name, ui_options)
format = I18n.t "time.formats.#{ui_options[:format] || :picker}", default: '' if ui_name == :datetime_picker
return super if format.blank?
parts = Date._parse(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 record_for_update_column
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def record_for_update_column
@record = find_if_allowed(params[:id], :read)
raise ActiveScaffold::ActionNotAllowed unless @record.authorized_for?(crud_type: :update, column: @column.name)
if @column.delegated_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 do_edit_associated
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def do_edit_associated
@scope = params[:scope]
@parent_record = params[:id].nil? ? new_parent_record : find_if_allowed(params[:id], :update)
cache_generated_id(@parent_record, params[:generated_id]) if @parent_record.new_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 do_add_existing
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def do_add_existing
parent_record = nested_parent_record(:update)
@record = active_scaffold_config.model.find(params[:associated_id])
if parent_record && @record
self.successful = false unless parent_record.send(nested.association.name) << @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 current_form_columns
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def current_form_columns(record, scope, subform_controller = nil)
if scope
subform_controller.active_scaffold_config.subform.columns.visible_columns_names
elsif %i[new create edit update render_field].include? action_name.to_sym
# disable update_columns for inplace_edit (GET render_field)
- 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 nested_chain_with_association
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def nested_chain_with_association
if nested.association.collection?
nested_parent_record.send(nested.association.name)
elsif nested.association.through? # has_one :through
active_scaffold_config.model.where(active_scaffold_config.model.primary_key => nested_parent_record.send(nested.association.name)&.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 format_number_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def format_number_value(value, options = {})
if value
value =
case options[:format]
when :size
- 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def loading_indicator_id(options = {})
options[:action] ||= params[:action]
options[:id] ||= params[:id]
options[:id] ||= nested_parent_id if nested?
clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-loading-indicator"
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 40.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid deeply nested control flow statements. Open
options[:size] ||= options[:maxlength].to_i > 30 ? 30 : options[:maxlength]
Method reverse_association
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def reverse_association(klass = nil)
assoc =
if polymorphic?
get_reverse(klass) unless klass.nil?
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"