Showing 107 of 107 total issues
Function _query
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
_query: function (query, success) {
var i,
matches = [];
if (query === "") {
Similar blocks of code found in 2 locations. Consider refactoring. Open
additional_control = $(
'<input class="additional-fieldset default form-control form-control-sm" type="text" />'
)
.css(
"display",
- 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
Function _getResultSet
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getResultSet: function (request, data, xhr) {
var matcher = new RegExp(
$.ui.autocomplete.escapeRegex(request.term),
"i"
);
Method navigation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def navigation(parent_groups, nodes, level = 0)
nodes.collect do |node|
abstract_model = node.abstract_model
model_param = abstract_model.to_param
url = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
- 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 filter_scope
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def filter_scope(scope, filters, fields = config.list.fields.select(&:filterable?))
statements = []
filters.each_pair do |field_name, filters_dump|
filters_dump.each_value do |filter_dump|
- 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 _create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_create: function () {
var widget = this;
var dom_widget = widget.element;
var edit_url =
Function _getModal
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getModal: function () {
var widget = this;
if (!widget.dialog) {
widget.dialog = $(
'<div id="modal" class="modal fade">\
Method fields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def fields(*field_names, &block)
return all_fields if field_names.empty? && !block
if field_names.empty?
defined = _fields.select(&:defined)
- 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 build_statement_for_string_or_text
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def build_statement_for_string_or_text
return if @value.blank?
return ["(#{@column} = ?)", @value] if ['is', '='].include?(@operator)
- 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 field_wrapper_for
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def field_wrapper_for(field, nested_in)
# do not show nested field if the target is the origin
return if nested_field_association?(field, nested_in)
@template.content_tag(:div, class: "control-group row mb-3 #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do
- 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 _move
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_move: function (direction, options) {
var widget = this;
if (direction == "up") {
options.each(function (i, option) {
var prev = $(option).prev();
Function _getSourceFunction
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getSourceFunction: function (source) {
var self = this;
var requestIndex = 0;
if ($.isArray(source)) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else {
$(option)
.clone()
.appendTo(widget.collection)
.prop("selected", false)
- 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 58.
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 (option.selected) {
$(option)
.clone()
.appendTo(widget.selection)
.prop("selected", false)
- 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 58.
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 reset
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset
@compact_show_view = true
@browser_validations = true
@authenticate = nil
@authorize = nil
Function _create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_create: function () {
this.filtering_select = this.element.siblings(
'[data-input-for="' + this.element.attr("id") + '"]'
);
Method add
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add(field, value, operator)
field.searchable_columns.flatten.each do |column_infos|
statement, value1, value2 = StatementBuilder.new(column_infos[:column], column_infos[:type], value, operator, @scope.connection.adapter_name).to_statement
@statements << statement if statement.present?
@values << value1 unless value1.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 extended
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.extended(object)
object.associations.each do |name, association|
association = Association.new(association, object.class)
case association.macro
when :has_many
- 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 type
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def type
case property.type.to_s
when 'Array', 'Hash', 'Money'
:serialized
when 'BigDecimal'
Function change
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
change: function (event, ui) {
if (ui.item) {
return;
}