Showing 1,556 of 1,556 total issues
Method validate_each
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
- 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 set_globals
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def set_globals
if attributes.present?
attributes.each do |arg|
# prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
if is_attachment(arg)
- 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
Perceived complexity for filter is too high. [16/7] Open
def filter(params)
# build conditions if specific params are present
conditions = {}
conditions[:user_id] = params['user'] if params['user'].present?
conditions[:changeable_type] = params['model'] if params['model'].present?
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method has too many lines. [19/10] Open
def change_item_link(change)
text = "#{change.changeable_type.gsub('Fae::','')}: "
test_source_method = :data_source_exists?
if change.changeable_type.exclude?('Fae') && change.changeable_type.exclude?('Page') && !ActiveRecord::Base.connection.send(test_source_method, change.changeable_type.tableize)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for get is too high. [24.66/15] Open
def get(endpoint)
begin
uri = URI.parse(endpoint)
request = Net::HTTP::Get.new(uri)
set_headers(request)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Function multiselectChosenActions
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
multiselectChosenActions: function() {
var query_input_select = '.input.select';
// Ignore select elements with .multiselect classes, because these are used for a different widget
var query_eligible_multiselects = query_input_select + ' select[multiple]:not(.multiselect)';
var select_all_value = 'multiselect_action-select_all';
Assignment Branch Condition size for update_parent is too high. [23.96/15] Open
def update_parent
parent = self.try(:imageable) || self.try(:fileable) || self.try(:contentable)
if parent.present?
latest_change = parent.try(:tracked_changes).try(:first)
if latest_change.present? && latest_change.change_type == 'updated' && latest_change.updated_at > 2.seconds.ago
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for clone_has_many_relationships is too high. [23.22/15] Open
def clone_has_many_relationships(association)
if @item.send(association).present?
@item.send(association).reverse.each do |record|
new_record = association.to_s.classify.constantize.find_by_id(record.id).dup
new_record.send("#{@klass_singular}_id" + '=', @cloned_item.id) if new_record.send("#{@klass_singular}_id").present?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for setup_dynamic_singleton is too high. [22.2/15] Open
def self.setup_dynamic_singleton
return if @singleton_is_setup
fae_fields.each do |name, value|
type = value.is_a?(Hash) ? value[:type] : value
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [17/10] Open
def self.setup_dynamic_singleton
return if @singleton_is_setup
fae_fields.each do |name, value|
type = value.is_a?(Hash) ? value[:type] : value
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for fae_filter_form is too high. [22.41/15] Open
def fae_filter_form(options = {}, &block)
options = prepare_options_for_filter_form options
return if options[:collection].blank?
form_tag(options[:action], prepare_form_filter_hash(options)) do
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [17/10] Open
def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [16/10] Open
def update_parent
parent = self.try(:imageable) || self.try(:fileable) || self.try(:contentable)
if parent.present?
latest_change = parent.try(:tracked_changes).try(:first)
if latest_change.present? && latest_change.change_type == 'updated' && latest_change.updated_at > 2.seconds.ago
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for update is too high. [21.31/15] Open
def update
if params[:form_manager].present?
fields_serialized = params[:form_manager][:fields].to_json
conditions = {
form_manager_model_name: params[:form_manager][:form_manager_model_name],
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [16/10] Open
def td_columns(params)
attribute = params[:col]
attributes = params[:cols]
item = params[:item]
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for authorize_model is too high. [21.1/15] Open
def authorize_model(model)
return false if current_user.blank? || current_user.role.blank? || current_user.role.name.blank?
users_role = current_user.role.name.downcase
tableized_model = model.name.tableize
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [15/10] Open
def add_update_change
if has_parent?
update_parent
else
return if legit_updated_attributes.blank?
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Function _setupField
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
_setupField: function($container, overriddenLabel, overriddenHelper) {
var _this = this;
if ($container.length) {
var $label = $container.find('label:first');
var $helperTextContainerEl = $container.find('h6');
- 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 clone_has_one_relationship
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def clone_has_one_relationship(association,type)
old_record = @item.send(association)
if old_record.present?
new_record = old_record.dup
- 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
Assignment Branch Condition size for language_support is too high. [20.27/15] Open
def language_support(f, attribute, options)
return if Fae.languages.blank?
attribute_array = attribute.to_s.split('_')
language_suffix = attribute_array.pop
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric