Method definitions that aren't used can be removed. Some examples of purposeless method definitions include empty constructors and methods just delegating to super.
The hash contains duplicate keys. While this is allowed by Ruby, this usually happens due to typos, and is, in most cases, unintended.
Each method in a scope should have a unique name. Having multiple methods with the same name is usually a result of typos.
each_with_object
is called with an immutable argument RB-LI1014Since the argument is the object that the given block shall make calls on to build something based on the enumerable that eachwithobject iterates over, an immutable argument makes no sense. It's definitely a bug.
ensure
block detected RB-LI1016The ensure
block must not be empty.
when
branch without a body detected RB-LI1019END
detected in a method RB-LI1020END
block is detected in a method. at_exit
should be used instead.
The parameters supplied for formatting the string do not match the specified parameters.
Methods on a heredoc should be invoked at beginning, not at the end.
Interpolations do not work in single-quote strings. Double quotes must be used.
while
/until
detected in begin
block RB-LI1033while
/until
should be used at the beginning of the block, and without the begin
statement.
In math and Python, we can use x < y < z
style comparison to compare multiple value. However, we can't use the comparison in Ruby. However, the comparison is not syntax error. This cop checks the bad usage of comparison operators.
Rails.env
predicate does not exist RB-RL1056Environments called with Rails.env
should exist. The default values are development
, test
and production
. More can be added in the Environments
array in .rubocop.yml
.
If an unused block argument is intended, it should be prefixed with an underscore.
Leaving a trailing comma in attribute declarations, such as #attr_reader
will nullify the next method definition by overriding it with a getter method.
Two adjacent string constants are found on the same line that are being concatenated. However, this is usually a typo, and some separator is missing.
A function argument is shadowed. It is usually a result of a typo.
==
for comparison instead of recommended equal?
method RB-LI1100Prefer Object#equal?
method for comparison instead of ==
as the latter is provided for performing value comparisons, whereas equal?
is provided to compare objects for identity.