Codeminer42/cm42-central

View on GitHub
app/models/team.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use find_by instead of dynamic find_by_project_id.
Open

    ownerships.find_by_project_id(project.id)&.is_owner
Severity: Minor
Found in app/models/team.rb by rubocop

This cop checks dynamic find_by_* methods. Use find_by instead of dynamic method. See. https://github.com/bbatsov/rails-style-guide#find_by

Example:

# bad
User.find_by_name(name)

# bad
User.find_by_name_and_email(name)

# bad
User.find_by_email!(name)

# good
User.find_by(name: name)

# good
User.find_by(name: name, email: email)

# good
User.find_by!(email: email)

Use find_by instead of dynamic find_by_user_id.
Open

    enrollments.find_by_user_id(user.id)&.is_admin?
Severity: Minor
Found in app/models/team.rb by rubocop

This cop checks dynamic find_by_* methods. Use find_by instead of dynamic method. See. https://github.com/bbatsov/rails-style-guide#find_by

Example:

# bad
User.find_by_name(name)

# bad
User.find_by_name_and_email(name)

# bad
User.find_by_email!(name)

# good
User.find_by(name: name)

# good
User.find_by(name: name, email: email)

# good
User.find_by!(email: email)

Do not freeze immutable objects, as freezing them has no effect.
Open

  DOMAIN_SEPARATORS_REGEX = /[,;\|\n]/.freeze
Severity: Minor
Found in app/models/team.rb by rubocop

This cop check for uses of Object#freeze on immutable objects.

Example:

# bad
CONST = 1.freeze

# good
CONST = 1

Rename is_admin? to admin?.
Open

  def is_admin?(user)
Severity: Minor
Found in app/models/team.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value) ...

# good
def even?(value)

# bad
def has_value? ...

# good
def value? ...

There are no issues that match your filters.

Category
Status