app/helpers/profiles_helper.rb

Summary

Maintainability
A
25 mins
Test Coverage

Module has too many lines. [122/100]
Open

module ProfilesHelper
  # Override for ActiveScaffold rules column for basket profiles
  # Refer to http://activescaffold.com/docs/form-overrides for details
  # If a new record, for each form type, create a dropdown with the rule types
  # when the rule type is 'some', dropdown the rules selection settings
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [24/10]
Open

  def rules_form_column(record, input_name)
    html = ''
    if record.new_record?
      html = '<div id="rules_forms" style="display: inline-block; margin-left: 2em;">'
      type_options = [[t('profiles_helper.rules_form_column.choose_included_fields'), '']] + Profile.type_options
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for rules_form_column is too high. [28.09/15]
Open

  def rules_form_column(record, input_name)
    html = ''
    if record.new_record?
      html = '<div id="rules_forms" style="display: inline-block; margin-left: 2em;">'
      type_options = [[t('profiles_helper.rules_form_column.choose_included_fields'), '']] + Profile.type_options
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [14/10]
Open

  def rules_allowed_check_box(name)
    @profile_sections ||= []
    @profile_sections << name

    content = check_box_tag(
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for rules_check_box_tag is too high. [18.68/15]
Open

  def rules_check_box_tag(name, value, label, is_array = false)
    '<div class="form-element">' +
      check_box_tag(
        "#{@rule_locals[:values_field_prefix]}[#{name}]#{'[]' if is_array}", value,
        (is_array && current_value_for(name).is_a?(Array) ? current_value_for(name).include?(value) : current_value_for(name) == value),
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

  def rules_check_box_tag(name, value, label, is_array = false)
    '<div class="form-element">' +
      check_box_tag(
        "#{@rule_locals[:values_field_prefix]}[#{name}]#{'[]' if is_array}", value,
        (is_array && current_value_for(name).is_a?(Array) ? current_value_for(name).include?(value) : current_value_for(name) == value),
Severity: Minor
Found in app/helpers/profiles_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

TODO found
Open

  # TODO Convert this to use Rails 2.3 try() method when available
Severity: Minor
Found in app/helpers/profiles_helper.rb by fixme

TODO found
Open

  # TODO Convert this to use Rails 2.3 try() method when available
Severity: Minor
Found in app/helpers/profiles_helper.rb by fixme

TODO found
Open

  # TODO Convert this to use Rails 2.3 try() method when available
Severity: Minor
Found in app/helpers/profiles_helper.rb by fixme

rescue at 45, 90 is not aligned with end at 46, 2.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:allowed].include?(field); rescue; false;
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks whether the rescue and ensure keywords are aligned properly.

Example:

# bad
begin
  something
  rescue
  puts 'error'
end

# good
begin
  something
rescue
  puts 'error'
end

Do not use semicolons to terminate expressions.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:allowed].include?(field); rescue; false;
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multiple expressions placed on the same line. It also checks for lines terminated with a semicolon.

Example:

# bad
foo = 1; bar = 2;
baz = 3;

# good
foo = 1
bar = 2
baz = 3

rescue at 39, 61 is not aligned with end at 40, 2.
Open

    ; params[:record][:rules][form_type.to_sym][:rule_type]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks whether the rescue and ensure keywords are aligned properly.

Example:

# bad
begin
  something
  rescue
  puts 'error'
end

# good
begin
  something
rescue
  puts 'error'
end

Prefer single-quoted strings inside interpolations.
Open

        html += "<div id=\"record_rules_#{form_type}_form\"#{" style=\"display:none;\"" if current_rule_for(form_type) != 'some'}>"
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks that quotes inside the string interpolation match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
result = "Tests #{success ? "PASS" : "FAIL"}"

# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"

Example: EnforcedStyle: double_quotes

# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"

# good
result = "Tests #{success ? "PASS" : "FAIL"}"

rescue at 51, 87 is not aligned with end at 52, 2.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:values][field.to_sym]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks whether the rescue and ensure keywords are aligned properly.

Example:

# bad
begin
  something
  rescue
  puts 'error'
end

# good
begin
  something
rescue
  puts 'error'
end

Do not use semicolons to terminate expressions.
Open

    ; params[:record][:rules][form_type.to_sym][:rule_type]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multiple expressions placed on the same line. It also checks for lines terminated with a semicolon.

Example:

# bad
foo = 1; bar = 2;
baz = 3;

# good
foo = 1
bar = 2
baz = 3

Do not use semicolons to terminate expressions.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:allowed].include?(field); rescue; false;
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multiple expressions placed on the same line. It also checks for lines terminated with a semicolon.

Example:

# bad
foo = 1; bar = 2;
baz = 3;

# good
foo = 1
bar = 2
baz = 3

Use \ instead of + or << to concatenate those strings.
Open

      '</div>' +
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

Avoid rescuing without specifying an error class.
Open

    ; params[:record][:rules][form_type.to_sym][:rule_type]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

Example: EnforcedStyle: implicit

# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.

# bad
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Example: EnforcedStyle: explicit (default)

# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.

# bad
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Use \ instead of + or << to concatenate those strings.
Open

      '</div>' +
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for string literal concatenation at the end of a line.

Example:

# bad
some_str = 'ala' +
           'bala'

some_str = 'ala' <<
           'bala'

# good
some_str = 'ala' \
           'bala'

Do not use semicolons to terminate expressions.
Open

    ; params[:record][:rules][form_type.to_sym][:rule_type]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multiple expressions placed on the same line. It also checks for lines terminated with a semicolon.

Example:

# bad
foo = 1; bar = 2;
baz = 3;

# good
foo = 1
bar = 2
baz = 3

Avoid multi-line ternary operators, use if or unless instead.
Open

    value ? "#{@rule_locals[:field_id_prefix]}_values_#{name}_#{value}" \
          : "#{@rule_locals[:field_id_prefix]}_values_#{name}"
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multi-line ternary op expressions.

Example:

# bad
a = cond ?
  b : c
a = cond ? b :
    c
a = cond ?
    b :
    c

# good
a = cond ? b : c
a =
  if cond
    b
  else
    c
  end

Avoid rescuing without specifying an error class.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:allowed].include?(field); rescue; false;
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

Example: EnforcedStyle: implicit

# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.

# bad
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Example: EnforcedStyle: explicit (default)

# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.

# bad
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Avoid rescuing without specifying an error class.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:values][field.to_sym]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

Example: EnforcedStyle: implicit

# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.

# bad
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Example: EnforcedStyle: explicit (default)

# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.

# bad
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Do not use semicolons to terminate expressions.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:values][field.to_sym]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multiple expressions placed on the same line. It also checks for lines terminated with a semicolon.

Example:

# bad
foo = 1; bar = 2;
baz = 3;

# good
foo = 1
bar = 2
baz = 3

Do not use semicolons to terminate expressions.
Open

    ; params[:record][:rules][@rule_locals[:form_type].to_sym][:values][field.to_sym]; rescue; '';
Severity: Minor
Found in app/helpers/profiles_helper.rb by rubocop

This cop checks for multiple expressions placed on the same line. It also checks for lines terminated with a semicolon.

Example:

# bad
foo = 1; bar = 2;
baz = 3;

# good
foo = 1
bar = 2
baz = 3

There are no issues that match your filters.

Category
Status