app/admin/user.rb

Summary

Maintainability
A
1 hr
Test Coverage

Block has too many lines. [83/25]
Open

ActiveAdmin.register User do
  actions :index, :show, :new, :create, :edit, :update

  filter :last_name
  filter :first_name
Severity: Minor
Found in app/admin/user.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [31/25]
Open

  show do
    attributes_table do
      row :email_address
      row :first_name
      row :last_name
Severity: Minor
Found in app/admin/user.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method role_ids_to_roles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def role_ids_to_roles
      roles = []
      role_id_params.each do |id|
        next unless id.present?
        role = Role.find(id) or next
Severity: Minor
Found in app/admin/user.rb - About 45 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

Use if id.blank? instead of unless id.present?.
Open

        next unless id.present?
Severity: Minor
Found in app/admin/user.rb by rubocop

This cops checks for code that can be changed to blank?. Settings: NilOrEmpty: Convert checks for nil or empty? to blank? NotPresent: Convert usages of not present? to blank? UnlessPresent: Convert usages of unless present? to blank?

Example:

# NilOrEmpty: true
  # bad
  foo.nil? || foo.empty?
  foo == nil || foo.empty?

  # good
  foo.blank?

# NotPresent: true
  # bad
  !foo.present?

  # good
  foo.blank?

# UnlessPresent: true
  # bad
  something unless foo.present?
  unless foo.present?
    something
  end

  # good
  something if foo.blank?
  if foo.blank?
    something
  end

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    panel "Delegate For" do
      table_for user.incoming_delegations do |tbl|
        tbl.column("ID") { |delegation| link_to delegation.id, admin_user_delegate_path(delegation) }
        tbl.column("User")  { |delegation| link_to delegation.assigner.display_name, admin_user_path(delegation.assigner) }
Severity: Minor
Found in app/admin/user.rb and 1 other location - About 25 mins to fix
app/admin/user.rb on lines 78..81

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    panel "Delegates To" do
      table_for user.outgoing_delegations do |tbl|
        tbl.column("ID") { |delegation| link_to delegation.id, admin_user_delegate_path(delegation) }
        tbl.column("User")  { |delegation| link_to delegation.assignee.display_name, admin_user_path(delegation.assignee) }
Severity: Minor
Found in app/admin/user.rb and 1 other location - About 25 mins to fix
app/admin/user.rb on lines 85..88

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Unnecessary spacing detected.
Open

        tbl.column("User")  { |delegation| link_to delegation.assigner.display_name, admin_user_path(delegation.assigner) }
Severity: Minor
Found in app/admin/user.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Pass &:name as an argument to column instead of a block.
Open

        tbl.column("Name") { |proposal| proposal.name }
Severity: Minor
Found in app/admin/user.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Pass &:status as an argument to column instead of a block.
Open

        tbl.column("Status") { |proposal| proposal.status }
Severity: Minor
Found in app/admin/user.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Pass &:created_at as an argument to column instead of a block.
Open

        tbl.column("Submitted") { |proposal| proposal.created_at }
Severity: Minor
Found in app/admin/user.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Use %i or %I for an array of symbols.
Open

  action_item :add_delegate, only: [:edit, :show] do
Severity: Minor
Found in app/admin/user.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Unnecessary spacing detected.
Open

        tbl.column("User")  { |delegation| link_to delegation.assignee.display_name, admin_user_path(delegation.assignee) }
Severity: Minor
Found in app/admin/user.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

There are no issues that match your filters.

Category
Status