Showing 20 of 22 total issues
Method render
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def render(context)
@context = context
@limit = context[@limit].present? ? context[@limit] : (@limit.present? ? @limit.to_i : nil)
@per_page = context[@per_page].present? ? context[@per_page] : (@per_page.present? ? @per_page.to_i : nil)
@order = context[@attributes['order']].present? ? context[@attributes['order']] : @attributes['order']
- 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 validate_preset_styles
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def validate_preset_styles(preset)
@errors << 'Preset is missing group_name' unless preset['group_name'].is_a?(String)
@errors << 'Preset is missing styles' unless preset['styles'].is_a?(Array)
preset['styles'].each do |style|
- 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 Store
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Store
include HTTParty
format :json
default_timeout 5
Class Theme
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Theme
REQUIRED_FILES = %w( cart.html contact.html home.html layout.html maintenance.html product.html products.html screenshot.jpg settings.json theme.css theme.js )
attr_reader :errors
Method render
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render(context)
@context = context
@limit = context[@limit].present? ? context[@limit] : (@limit.present? ? @limit.to_i : nil)
@per_page = context[@per_page].present? ? context[@per_page] : (@per_page.present? ? @per_page.to_i : nil)
@order = context[@attributes['order']].present? ? context[@attributes['order']] : @attributes['order']
Class ProductDrop
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ProductDrop < BaseDrop
def created_at
Time.parse(source['created_at'])
end
Method customization_for_type
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def customization_for_type(type)
Hash.new.tap do |hash|
if settings.has_key?(type)
case type
when 'images'
- 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 default_pagination
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def default_pagination(paginate, div_id = 'pagination', div_class = 'pagination', prev_label = nil, next_label = nil)
Array.new.tap { |html|
html << %(<div class="#{ div_class }" id="#{ div_id }">)
prev_label = prev_label.blank? ? paginate['previous']['title'] : prev_label
- 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 number_with_precision
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def number_with_precision(number, options={})
options.symbolize_keys!
number = begin
Float(number)
- 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 tag_options
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def tag_options(options, escape = true)
unless options.blank?
attrs = []
if escape
options.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
Method add_item
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def add_item(add)
id = add[:id].to_i
unless item = items.find { |i| i.option['id'] == id.to_i }
product, option = Dugway.store.product_and_option(id)
- 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 number_with_precision
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def number_with_precision(number, options={})
options.symbolize_keys!
number = begin
Float(number)
Method render
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def render(context)
@context = context
@number_to_get = if context[@number_to_get].present?
context[@number_to_get]
- 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 before_method
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def before_method(method_or_key)
if respond_to?(method_or_key)
# don't do anything, just let it default here
elsif source.respond_to?(method_or_key)
return source.send(method_or_key)
- 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 number_to_currency
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def number_to_currency(number, options={})
return unless number
options.symbolize_keys!
- 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 valid?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def valid?
@errors = []
REQUIRED_FILES.each do |file|
@errors << "Missing source/#{ file }" if read_source_file(file).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 default_pagination
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def default_pagination(paginate, div_id = 'pagination', div_class = 'pagination', prev_label = nil, next_label = nil)
Method render
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def render(request, variables={})
if html?
liquifier = Liquifier.new(request)
content_to_render = variables[:page] && variables[:page]['content'] || content
rendered_content = liquifier.render(content_to_render, variables)
- 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 validate_keys
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_keys(preset, settings, key_type)
variables = settings.map { |item| item['variable'] }
preset['styles'].each do |style|
style_keys = style[key_type].keys
- 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 validate_preview
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_preview
preview = settings['preset_styles']['preview']
if preview
%w[title_font body_font text_color background_color].each do |key|
@errors << "Missing #{key} in preview" unless preview[key]
- 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"