app/models/team.rb
Use find_by
instead of dynamic find_by_project_id
. Open
Open
ownerships.find_by_project_id(project.id)&.is_owner
- Read upRead up
- Exclude checks
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
Open
enrollments.find_by_user_id(user.id)&.is_admin?
- Read upRead up
- Exclude checks
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
Open
DOMAIN_SEPARATORS_REGEX = /[,;\|\n]/.freeze
- Read upRead up
- Exclude checks
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
Open
def is_admin?(user)
- Read upRead up
- Exclude checks
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? ...