app/models/role.rb
Missing top-level class documentation comment. Open
Open
class Role < ApplicationRecord
- Read upRead up
- Exclude checks
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
Prefer annotated tokens (like %<foo>s</foo>
) over template tokens (like %{foo}
). Open
Open
validates :name, inclusion: { in: %w(client manager employee), message: '%{value} is not a permitted role' }
- Read upRead up
- Exclude checks
Use a consistent style for named format string tokens.
Note:
unannotated
style cop only works for strings
which are passed as arguments to those methods:
sprintf
, format
, %
.
The reason is that unannotated format is very similar
to encoded URLs or Date/Time formatting strings.
Example: EnforcedStyle: annotated (default)
# bad
format('%{greeting}', greeting: 'Hello')
format('%s', 'Hello')
# good
format('%<greeting>s', greeting: 'Hello')</greeting>
Example: EnforcedStyle: template
# bad
format('%<greeting>s', greeting: 'Hello')
format('%s', 'Hello')
# good
format('%{greeting}', greeting: 'Hello')</greeting>
Example: EnforcedStyle: unannotated
# bad
format('%<greeting>s', greeting: 'Hello')
format('%{greeting}', 'Hello')
# good
format('%s', 'Hello')</greeting>
Line is too long. [110/80] Open
Open
validates :name, inclusion: { in: %w(client manager employee), message: '%{value} is not a permitted role' }
- Exclude checks
Prefer has_many :through
to has_and_belongs_to_many
. Open
Open
has_and_belongs_to_many :users, join_table: :users_roles
- Read upRead up
- Exclude checks
This cop checks for the use of the hasandbelongstomany macro.
Example:
# bad
# has_and_belongs_to_many :ingredients
# good
# has_many :ingredients, through: :recipe_ingredients