lujanfernaud/prevy

View on GitHub
app/helpers/groups_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage

GroupsHelper#checked_if_not_set? is controlled by argument 'attribute'
Open

    attribute ? false : true
Severity: Minor
Found in app/helpers/groups_helper.rb by reek

Control Parameter is a special case of Control Couple

Example

A simple example would be the "quoted" parameter in the following method:

def write(quoted)
  if quoted
    write_quoted @value
  else
    write_unquoted @value
  end
end

Fixing those problems is out of the scope of this document but an easy solution could be to remove the "write" method alltogether and to move the calls to "writequoted" / "writeunquoted" in the initial caller of "write".

GroupsHelper has no descriptive comment
Open

module GroupsHelper
Severity: Minor
Found in app/helpers/groups_helper.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

GroupsHelper#has_member_role_and_is_confirmed? doesn't depend on instance state (maybe move it to another class?)
Open

  def has_member_role_and_is_confirmed?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

GroupsHelper takes parameters ['group', 'user'] to 7 methods
Open

  def has_moderator_role?(user, group)
    user&.has_role? :moderator, group
  end

  def has_member_role_and_is_confirmed?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by reek

In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

Example

Given

class Dummy
  def x(y1,y2); end
  def y(y1,y2); end
  def z(y1,y2); end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

A possible way to fix this problem (quoting from Martin Fowler):

The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

GroupsHelper#has_membership? doesn't depend on instance state (maybe move it to another class?)
Open

  def has_membership?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

GroupsHelper#is_group_owner? doesn't depend on instance state (maybe move it to another class?)
Open

  def is_group_owner?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Rename is_group_owner? to group_owner?.
Open

  def is_group_owner?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Rename has_membership? to membership?.
Open

  def has_membership?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Missing top-level module documentation comment.
Open

module GroupsHelper
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Rename has_member_role_and_is_confirmed? to member_role_and_is_confirmed?.
Open

  def has_member_role_and_is_confirmed?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Rename has_membership_but_is_not_confirmed? to membership_but_is_not_confirmed?.
Open

  def has_membership_but_is_not_confirmed?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Rename has_membership_and_is_confirmed? to membership_and_is_confirmed?.
Open

  def has_membership_and_is_confirmed?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

Rename has_moderator_role? to moderator_role?.
Open

  def has_moderator_role?(user, group)
Severity: Minor
Found in app/helpers/groups_helper.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

There are no issues that match your filters.

Category
Status