Showing 27 of 27 total issues
Method admin_resources
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def admin_resources(*resources, &block)
options = resources.extract_options!.dup
if apply_common_behavior_for(:admin_resources, resources, options, &block)
return self
- 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 editorConfig
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
CKEDITOR.editorConfig = function (config) {
config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
- 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
Class DataItems
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class DataItems
include ::Enumerable
def initialize
@data_items = {}
Class DataItem
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class DataItem
# TODO extract sub classes
attr_accessor :name, :field, :relation, :label, :uploader, :order_column, :form_params,
Class ModelController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ModelController < RademadeAdmin::AbstractController
extend RademadeAdmin::ModelOptions
include RademadeAdmin::InstanceOptions
Function editorConfig
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
CKEDITOR.editorConfig = function (config) {
config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
Method _map_relations
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _map_relations
relations = {}
@model.reflections.each do |name, relation_info|
name = name.to_sym
type = relation_info.macro
- 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 _map_relations
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _map_relations
relations = {}
@model.relations.each do |name, relation_info|
name = name.to_sym
type = relation_info.relation.macro
- 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_items
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def build_items
data_items = RademadeAdmin::Model::Info::DataItems.new
used_relations = []
# TODO extract sub - methods
- 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 admin_resources
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def admin_resources(*resources, &block)
options = resources.extract_options!.dup
if apply_common_behavior_for(:admin_resources, resources, options, &block)
return self
Method template_paths
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def template_paths
@template_paths ||= {
:main_layout => layout_path('main'),
:login_layout => layout_path('login'),
:content_item_layout => layout_path('content_item'),
Method delete_other_images
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def delete_other_images(image_path)
filename = File.basename(image_path)
store_path = full_image_path(store_dir)
- 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 2 locations. Consider refactoring. Open
def build_where_condition(field: nil, value: nil)
field = table_field(field)
if value.is_a? Regexp
["LOWER(#{field}) ~* ?", [value.source]]
- 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 39.
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
def build_where_condition(field: nil, value: nil)
field = table_field(field)
if value.is_a? Regexp
["LOWER(#{field}) REGEXP LOWER(?)", [value.source]]
elsif value.is_a? Array
- 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 39.
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 crop
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def crop(image_path, x, y, width, height)
Method collect_where_conditions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def collect_where_conditions(where_conditions)
condition = ''
values = []
where_conditions.parts.each do |part|
condition += " #{where_conditions.type.to_s.capitalize} " unless condition.empty?
- 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 save_model_upload
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def save_model_upload(data_item, image_path)
if item.try(:translation).respond_to? data_item.setter
entity = item.translation
else
entity = item
- 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 collect_children
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def collect_children(menu_key)
menu = []
menu_key = menu_key.to_s
unless @menu_data[menu_key].nil?
@menu_data[menu_key].each do |model_info|
- 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 display_item_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def display_item_value(item, data_item)
if data_item.list_preview_handler.nil?
value = item.send(data_item.list_preview_accessor)
return display_upload_item(value) if data_item.has_uploader?
return display_related_item(data_item, item, value) if data_item.has_relation?
- 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 save_localizable_fields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def save_localizable_fields
current_locale = I18n.locale
@model_info.data_items.localizable_fields.each do |_, data_item|
values = @params[:data].try(:[], data_item.name)
values.each do |locale, 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"