Showing 362 of 362 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (child.tagName != 'SCRIPT'
&& !child.hasClassName("create")
&& !child.hasClassName("update")
&& !child.hasClassName("inline-adapter")
&& !child.hasClassName("active-scaffold-calculations")) {
- 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 66.
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
Method active_scaffold_input_radio
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def active_scaffold_input_radio(column, html_options, ui_options: column.options)
record = html_options[:object]
html_options.merge!(ui_options[:html_options] || {})
options =
if column.association
Method column_numerical_constraints
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def column_numerical_constraints(column, options)
validators = column.active_record_class.validators.select do |v|
v.is_a?(ActiveModel::Validations::NumericalityValidator) &&
v.attributes.include?(column.name) &&
!v.options[:if] && !v.options[:unless]
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (event.type == 'mouseleave') {
if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').removeClass("hover");
}
- 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 64.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (event.type == 'mouseenter') {
if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').addClass("hover");
}
- 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 64.
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
Method initialize
has 36 lines of code (exceeds 25 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)
Method _setup_bitfields
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _setup_bitfields
return unless model.respond_to?(:bitfields) && model.bitfields.present?
model.bitfields.each do |column_name, options|
columns = options.keys.sort_by { |column| self.columns[column].weight }
%i[create update show subform].each do |action|
- 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 look_for_parent_sti_controller
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def look_for_parent_sti_controller
klass = self.class.active_scaffold_config.model
loop do
klass = klass.superclass
controller = self.class.active_scaffold_controller_for(klass)
- 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_save
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update_save(attributes: params[:record], no_record_param_update: false)
active_scaffold_config.model.transaction do
unless no_record_param_update
@record = update_record_from_params(@record, active_scaffold_config.update.columns, attributes)
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 render_field_for_update_columns
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def render_field_for_update_columns
return if (@column = active_scaffold_config.columns[params.delete(:column)]).nil?
@source_id = params.delete(:source_id)
@columns = @column.update_columns || []
@scope = params.delete(:scope)
- 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 keeping_errors
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def keeping_errors
old_errors = errors.dup if errors.present?
result = yield
old_errors&.each do |e|
if e.is_a?(String) || e.is_a?(Symbol)
- 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_field_search
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def do_field_search
filtered_columns = []
text_search = active_scaffold_config.field_search.text_search
columns = active_scaffold_config.field_search.columns
search_params.each do |key, 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
Function update_column
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
update_column: function(element, url, send_form, source_id, val, additional_params) {
if (!element) element = $(source_id);
var as_form = element.up('form.as_form');
var params = null;
- 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 target_scope
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def target_scope
super.tap do |scope|
if klass < ActiveScaffold::Tableless
class << scope; include RelationExtension; end
assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
- 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 attributes_hash_is_empty?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def attributes_hash_is_empty?(hash, klass)
hash.all? do |key, value|
# convert any possible multi-parameter attributes like 'created_at(5i)' to simply 'created_at'
column_name = key.to_s.split('(', 2)[0]
- 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_column_from_params
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update_column_from_params(parent_record, column, attribute, avoid_changes = false)
value = column_value_from_param_value(parent_record, column, attribute, avoid_changes)
if column.association
if avoid_changes
parent_record.association(column.name).target = 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 find_page
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def find_page(options = {})
options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
options[:per_page] ||= 999_999_999
options[:page] ||= 1
- 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_numeric
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def condition_value_for_numeric(column, value)
return value if value.nil?
value = column.number_to_native(value) if column.options[:format] && column.search_ui != :number
case (column.search_ui || column.column_type)
when :integer then
- 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
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render(*args, &block)
if args.first.is_a?(Hash) && args.first[:active_scaffold]
render_embedded args.first
elsif args.first == :super
if @lookup_context # rails 6
Function update_column
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
update_column: function(element, url, send_form, source_id, val, additional_params) {
if (!element) element = $(source_id);
var as_form = element.up('form.as_form');
var params = null;