foodcoop-adam/foodsoft

View on GitHub
app/helpers/admin/configs_helper.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method config_input has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def config_input(form, key, options = {}, &block)
    return unless @cfg.allowed_key? key
    options[:label] ||= config_input_label(form, key)
    options[:required] ||= false
    options[:input_html] ||= {}
Severity: Minor
Found in app/helpers/admin/configs_helper.rb - About 2 hrs 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 config_input_field has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def config_input_field(form, key, options = {})
    return unless @cfg.allowed_key? key
    options[:required] ||= false
    config_input_field_options form, key, options
    config_input_tooltip_options form, key, options
Severity: Minor
Found in app/helpers/admin/configs_helper.rb - About 1 hr 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

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

There are no issues that match your filters.

Category
Status