Showing 33 of 66 total issues
Method update_model
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_model
inject_into_file "app/models/#{resource_name}.rb", "\n has_many :#{plural_child_name}, :through => :#{plural_linking_resource_name}\n has_many :#{plural_linking_resource_name}\n
# def self.has_not_this_#{child_name}(#{child_name}_id)
# h = Hash.new
# self.order(#{child_model.constantize.column_names.include?('title') ? '\'title\'' : 'created_at'}).each do |p|
Method has_not_this
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_not_this(model_name, *args)
options = args.extract_options!
join_model = options[:through].to_s.singularize.camelize
self_id_sym = "#{self.to_s.underscore}_id".to_sym
array_first_el = options[:by] ? options[:by] : :title
Method has_not_this
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def has_not_this(model_name, *args)
options = args.extract_options!
join_model = options[:through].to_s.singularize.camelize
self_id_sym = "#{self.to_s.underscore}_id".to_sym
array_first_el = options[:by] ? options[:by] : :title
- 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 deeply nested control flow statements. Open
if (option.group_array_index != null) {
$("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
}
Avoid deeply nested control flow statements. Open
if (parts.length) {
for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
part = parts[_j];
if (regex.test(part)) {
found = true;
Avoid deeply nested control flow statements. Open
if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
this.result_clear_highlight();
}
Avoid deeply nested control flow statements. Open
if (searchText.length) {
startpos = option.html.search(zregex);
text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
} else {
Consider simplifying this complex logical expression. Open
if (parentItem != null && nextItem == null &&
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
!o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
parentItem.after(this.placeholder[0]);
this._clearEmpty(parentItem[0]);
Method cropable
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def cropable(image_name, x,y,w,h)
Method update_model
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_model
inject_into_file "app/models/#{resource_name}.rb", "\n has_many :#{plural_child_name}, :through => :#{plural_linking_resource_name}\n has_many :#{plural_linking_resource_name}\n
# def self.has_not_this_#{child_name}(#{child_name}_id)
# h = Hash.new
# self.order(#{child_model.constantize.column_names.include?('title') ? '\'title\'' : 'created_at'}).each do |p|
- 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 function. Open
return colors[jQuery.trim(color).toLowerCase()];
Avoid too many return
statements within this function. Open
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
Method sortable_columns
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sortable_columns(column, title = nil)
title ||= column.titleize
css_class = column == sort_column ? "current #{sort_direction}" : nil
direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
link_to title, {:sort => column, :direction => direction}, {:class => css_class}
- 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"