foodcoop-adam/foodsoft

View on GitHub

Showing 131 of 150 total issues

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

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

  def show
    @order_ids = if params[:id]
                   params[:id].split('+').map(&:to_i)
                 else
                   Order.finished_not_closed.all.map(&: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 check_approval has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.check_approval(c, user)
    # short checks
    FoodsoftSignup.enabled? :approval or return true
    user and user.role_admin? and return true
    user and user.ordergroup and user.ordergroup.approved? and return true
Severity: Minor
Found in lib/foodsoft_signup/lib/foodsoft_signup/hooks.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 next_occurrence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.next_occurrence(start=Time.now, from=start, options={})
    if options[:recurr]
      schedule = IceCube::Schedule.new(start)
      schedule.add_recurrence_rule rule_from(options[:recurr])
      # @todo handle ical parse errors
Severity: Minor
Found in lib/foodsoft_date_util.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_upload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_upload
    @articles = Array.new
    articles, outlisted_articles = FoodsoftFile::parse(params[:articles]["file"])
    no_category = ArticleCategory.new
    articles.each do |row|
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 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 ws_return has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def ws_return(status, msg=nil)
    if status == :rejected
      logger.warn "foodsoft_adyen: #{msg}"
    elsif status == :error
      logger.error msg

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

  def config_input_tooltip_options(form, key, options)
    # tooltip with help info to the right
    cfg_path = form.lookup_model_names[1..-1] + [key]
    tooltip = I18n.t("config.hints.#{cfg_path.map(&:to_s).join('.')}", default: '')
    unless tooltip.blank?
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

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

    def select_language_according_to_priority
      language = explicitly_requested_language || session_language || user_settings_language
      language ||= browser_language unless FoodsoftConfig[:ignore_browser_locale]
      language.to_sym unless language.blank?
    end
Severity: Minor
Found in lib/foodsoft/controller_extensions/locale.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 heading_helper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def heading_helper(model, attribute, options = {})
    i18nopts = {count: 2}.merge(options.select {|a| !['short', 'desc'].include?(a) })
    s = model.human_attribute_name(attribute, i18nopts)
    if options[:short]
      desc = options[:desc]
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 deliver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def deliver
    for user in recipients
      if user.receive_email?
        begin
          MessagesMailer.foodsoft_message(self, user).deliver
Severity: Minor
Found in lib/foodsoft_messages/app/models/message.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