foodcoops/foodsoft

View on GitHub

Showing 134 of 182 total issues

Method sso has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def sso
    raise I18n.t('discourse.sso.invalid_signature') unless valid_signature?

    payload = parse_payload
    nonce = payload[:nonce]
Severity: Minor
Found in plugins/discourse/app/controllers/discourse_sso_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 starts_before_ends has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def starts_before_ends
    delta = Rails.env.test? ? 1 : 0 # since Rails 4.2 tests appear to have time differences, with this validation failing
    errors.add(:ends, I18n.t('orders.model.error_starts_before_ends')) if ends && starts && ends <= (starts - delta)
    errors.add(:ends, I18n.t('orders.model.error_boxfill_before_ends')) if ends && boxfill && ends <= (boxfill - delta)
    return unless boxfill && starts && boxfill <= (starts - delta)
Severity: Minor
Found in app/models/order.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 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
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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(options = {})
    options[:font_size] ||= FoodsoftConfig[:pdf_font_size].try(:to_f) || 12
    options[:page_size] ||= FoodsoftConfig[:pdf_page_size] || 'A4'
    options[:skip_page_creation] = true
    @options = options
Severity: Minor
Found in app/lib/render_pdf.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 enforce_boxfill has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def enforce_boxfill
    # Either nothing changes, or the tolerance increases,
    # missing_units decreases and the amount doesn't decrease, or
    # tolerance was moved to quantity. Only then are changes allowed in the boxfill phase.
    delta_q = quantity - quantity_was
Severity: Minor
Found in app/models/order_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 document has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def document
    return redirect_to pickups_path, alert: t('.empty_selection') unless params[:orders]

    order_ids = params[:orders].map(&:to_i)

Severity: Minor
Found in app/controllers/pickups_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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    order = Order.find(params[:order])
    state = order.open? ? 'queued' : 'ready'
    count = 0
    PrinterJob.transaction do
Severity: Minor
Found in plugins/printer/app/controllers/printer_jobs_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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @doc_options ||= {}
    @order_ids = if params[:id]
                   params[:id].split('+').map(&:to_i)
                 else

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

Avoid too many return statements within this method.
Open

    when 'suppliers'      then return current_user.role_suppliers?
Severity: Major
Found in app/controllers/concerns/auth_api.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        when 'finance'        then return current_user.role_finance?
    Severity: Major
    Found in app/controllers/concerns/auth_api.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false unless ftt
      Severity: Major
      Found in app/models/bank_transaction.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            when 'workgroups'     then return current_user.role_admin?
        Severity: Major
        Found in app/controllers/concerns/auth_api.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              when 'group_orders'   then return current_user.role_orders?
          Severity: Major
          Found in app/controllers/concerns/auth_api.rb - About 30 mins to fix

            Method order_article_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def order_article_class(order_article)
                if order_article.units > 0
                  if order_article.missing_units == 0
                    'used'
                  else
            Severity: Minor
            Found in app/helpers/orders_helper.rb - About 25 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 find_group_orders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def find_group_orders
                @order_ids = Order.finished_not_closed.map(&:id)
            
                @all_ordergroups = Ordergroup.undeleted.order(:name).to_a
                @ordered_group_ids = GroupOrder.where(order_id: @order_ids).pluck('DISTINCT(ordergroup_id)')

            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 bootstrap_flash_patched has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def bootstrap_flash_patched
                flash_messages = []
                flash.each do |type, message|
                  type = :success if type == 'notice'
                  type = :error   if type == 'alert'
            Severity: Minor
            Found in app/helpers/application_helper.rb - About 25 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 update_selected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def update_selected
                raise I18n.t('articles.controller.error_nosel') if params[:selected_articles].nil?
            
                articles = Article.find(params[:selected_articles])
                Article.transaction do
            Severity: Minor
            Found in app/controllers/articles_controller.rb - About 25 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 link_to_wikipage_by_permalink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def link_to_wikipage_by_permalink(permalink, text = nil)
                return if permalink.blank?
            
                page = Page.find_by_permalink(permalink)
                if page.nil?
            Severity: Minor
            Found in plugins/wiki/app/helpers/pages_helper.rb - About 25 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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.parse(input)
                return input unless input.is_a? String
            
                Rails.logger.debug { "Input: #{input.inspect}" }
                separator = I18n.t('separator', scope: 'number.format')
            Severity: Minor
            Found in app/models/concerns/localize_input.rb - About 25 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