Showing 131 of 150 total issues
Method link_to_ordering
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def link_to_ordering(order, options = {}, &block)
group_order = order.group_order(current_user.ordergroup)
path = if options[:show] and group_order
group_order_path(group_order)
elsif group_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 show_price_markup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show_price_markup(id, options = {})
list = FoodsoftConfig[:price_markup_list] or return
id = id.price_markup_key if id.is_a? Ordergroup
return if options[:optional] and id == FoodsoftConfig[:price_markup]
- 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 user_for_ordergroup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.user_for_ordergroup(ordergroup)
unless ordergroup.kind_of?(Ordergroup)
begin
ordergroup = Ordergroup.undeleted.find(ordergroup)
rescue ActiveRecord::RecordNotFound
- 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 body
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def body
OrderArticle.joins(:order, :article).where(:orders => {:id => @order}).ordered.order('orders.id, articles.name').each do |order_article|
rows = []
dimrows = []
- 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 login_foodsoft
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function login_foodsoft($username, $password, $ip = '', $borwser = '', $forwarded_for = '')
Method update_or_create_user
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_or_create_user(id, email, first_name, last_name, workgroups=[])
Method search_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def search_data(query, field)
# is_a? on ActiveRecord doesn't work http://stackoverflow.com/questions/7828666
if query.respond_to? :offset
limit = (params[:limit] or 10)
offset = (params[:offset] or 0)
- 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 login
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def login
# use cookies, but allow to get them from parameters (if on other domain)
sweets = params.select {|k,v| k=='Mem' or k=='Key'}
sweets.empty? and sweets = cookies
- 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 create_from_upload
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_from_upload
begin
Article.transaction do
invalid_articles = false
@articles = []
- 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 uniqueness_of_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def uniqueness_of_name
matches = Article.where(name: name, supplier_id: supplier_id, deleted_at: deleted_at, type: type)
matches = matches.where('id != ?', id) unless new_record?
if supplier.shared_sync_method.blank? or supplier.shared_sync_method == 'import'
errors.add :name, :taken if matches.any?
- 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 order_checks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def order_checks(order)
result = [] # array of [true/false/:warn/nil, message]
# need articles to order
if order.order_articles.ordered.count == 0
result << [false, I18n.t('helpers.orders.order_checks.none_ordered', count: order.order_articles.ordered.count)]
- 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 create_collection
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_collection
raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
params[:financial_transactions].each do |trans|
# ignore empty amount fields ...
unless trans[:amount].blank?
- 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 sort_link_helper
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sort_link_helper(text, key, options = {})
# Hmtl options
remote = options[:remote].nil? ? true : options[:remote]
class_name = case params[:sort]
when key then
- 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 accept_invitation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def accept_invitation
@invite = Invite.find_by_token(params[:token])
if @invite.nil? || @invite.expires_at < Time.now
redirect_to login_url, alert: I18n.t('login.controller.error_invite_invalid')
#elsif @invite.group.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 signup_warning
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.signup_warning(c, user)
FoodsoftSignup.enabled? :approval or return true
return true if FoodsoftConfig[:unapproved_allow_access]=='*'
if user
user.role_admin? and return true
- 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 show
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def show
require 'csv'
@users = select_users(:all)
fields = [:id, :name, :email, :phone, :ordergroup]
fields << :approved if defined? FoodsoftSignup
- 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 user_list=
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def user_list=(ids)
list = ids.split(",").map(&:to_i)
new_users = (list - users.collect(&:id)).uniq
old_users = users.reject { |user| list.include?(user.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 pkg_helper
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def pkg_helper(article, options={})
return '' if not article or article.unit_quantity == 1
uq_text = "× #{article.unit_quantity}"
uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq]
if options[:plain]
- 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_mollie_cfg
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_mollie_cfg
if mcfg = FoodsoftConfig[:mollie].try(&:symbolize_keys)
IdealMollie::Config.partner_id = mcfg[:partner_id] if mcfg[:partner_id]
IdealMollie::Config.profile_key = mcfg[:profile_key] if mcfg[:profile_key]
IdealMollie::Config.test_mode = mcfg[:test_mode] if mcfg[:test_mode]
- 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_order_result_attachments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_order_result_attachments
foodsoft_orderdoc_add_order_result_attachments
if FoodsoftOrderdoc.enabled? and FoodsoftOrderdoc.supplier_has_orderdoc?(@order.supplier)
Rails.logger.debug "Adding orderdoc to supplier mail for order #{@order.id}"
orderdoc = FoodsoftOrderdoc.orderdoc(@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"