foodcoops/foodsoft

View on GitHub

Showing 134 of 182 total issues

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

  def pkg_helper(article, options = {})
    return '' if !article || article.unit_quantity == 1

    uq_text = "× #{article.unit_quantity}"
    uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq]
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 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 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 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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.parse(file, options = {})
    filepath = file.is_a?(String) ? file : file.to_path
    filename = options.delete(:filename) || filepath
    fileext = File.extname(filename)
    options[:csv_options] = { col_sep: ';', encoding: 'utf-8' }.merge(options[:csv_options] || {})
Severity: Minor
Found in app/lib/spreadsheet_file.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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    sort = if params['sort']
             case params['sort']
             when 'name' then 'articles.name'
             when 'unit' then 'articles.unit'
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 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 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

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

          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

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

              def callback
                raise I18n.t('discourse.callback.invalid_signature') unless valid_signature?
            
                payload = parse_payload
            
            
            Severity: Minor
            Found in plugins/discourse/app/controllers/discourse_login_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 all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def all
                @pages = Page.non_redirected
                @partial = params[:view] || 'site_map'
            
                if params[:name]
            Severity: Minor
            Found in plugins/wiki/app/controllers/pages_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 redistribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def redistribute(quantity, surplus = [:tolerance], update_totals = true)
                qty_left = quantity
                counts = [0] * surplus.length
            
                if surplus.index(:tolerance).nil?
            Severity: Minor
            Found in app/models/order_article.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 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 uniqueness_of_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def uniqueness_of_name
                group = Ordergroup.where(name: name)
                group = group.where.not(id: id) unless new_record?
                return unless group.exists?
            
            
            Severity: Minor
            Found in app/models/ordergroup.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 show_config_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def show_config_value(key, value)
                if key =~ /passw|secr|key/
                  '(protected)'
                elsif value.is_a? Hash
                  content_tag :ul do
            Severity: Minor
            Found in app/helpers/admin/configs_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

            Severity
            Category
            Status
            Source
            Language