foodcoop-adam/foodsoft

View on GitHub

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
Severity: Minor
Found in app/helpers/group_orders_helper.rb - About 45 mins to fix

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]

Severity: Minor
Found in app/helpers/shared_helper.rb - About 45 mins to fix

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
Severity: Minor
Found in lib/foodsoft_vokomokum/lib/foodsoft_vokomokum/export.rb - About 45 mins to fix

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 = []
Severity: Minor
Found in lib/foodsoft_current_orders/app/documents/multiple_orders_by_articles.rb - About 45 mins to fix

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 = '')
Severity: Minor
Found in lib/foodsoft_userinfo/examples/phpbb3_auth_foodsoft.php - About 35 mins to fix

    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=[])
    Severity: Minor
    Found in lib/foodsoft_vokomokum/app/controllers/vokomokum_controller.rb - About 35 mins to fix

      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)
      Severity: Minor
      Found in app/controllers/application_controller.rb - About 35 mins to fix

      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
      
      
      Severity: Minor
      Found in lib/foodsoft_vokomokum/app/controllers/vokomokum_controller.rb - About 35 mins to fix

      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 = []
      Severity: Minor
      Found in app/controllers/articles_controller.rb - About 35 mins to fix

      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?
      Severity: Minor
      Found in app/models/article.rb - About 35 mins to fix

      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)]
      Severity: Minor
      Found in app/helpers/orders_helper.rb - About 35 mins to fix

      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?
      Severity: Minor
      Found in app/controllers/finance/financial_transactions_controller.rb - About 35 mins to fix

      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
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 35 mins to fix

      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?
      Severity: Minor
      Found in app/controllers/login_controller.rb - About 35 mins to fix

      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
      Severity: Minor
      Found in lib/foodsoft_signup/lib/foodsoft_signup/hooks.rb - About 35 mins to fix

      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
      Severity: Minor
      Found in lib/foodsoft_mailall/app/controllers/admin/mailall_controller.rb - About 35 mins to fix

      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) }
          
      Severity: Minor
      Found in app/models/task.rb - About 35 mins to fix

      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]
      Severity: Minor
      Found in app/helpers/orders_helper.rb - About 35 mins to fix

      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]
      Severity: Minor
      Found in lib/foodsoft_mollie/app/controllers/payments/mollie_ideal_controller.rb - About 35 mins to fix

      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)
      Severity: Minor
      Found in lib/foodsoft_orderdoc/lib/foodsoft_orderdoc/add_to_supplier_mail.rb - About 35 mins to fix

      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

      Severity
      Category
      Status
      Source
      Language