Ruby

Ruby

Made by DeepSource
Purposeless method definition detected RB-LI1097
Bug risk
Minor

Method definitions that aren't used can be removed. Some examples of purposeless method definitions include empty constructors and methods just delegating to super.

Hash contains duplicate keys RB-LI1012
Bug risk
Major

The hash contains duplicate keys. While this is allowed by Ruby, this usually happens due to typos, and is, in most cases, unintended.

Multiple methods with same name in the same scope RB-LI1013
Bug risk
Major

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-LI1014
Bug risk
Major

Since 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.

Empty ensure block detected RB-LI1016
Bug risk
Major
Autofix

The ensure block must not be empty.

Empty expression detected RB-LI1017
Bug risk
Major

when branch without a body detected RB-LI1019
Bug risk
Major

END detected in a method RB-LI1020
Bug risk
Major

END block is detected in a method. at_exit should be used instead.

Mismatch between specified and passed format params RB-LI1025
Bug risk
Major

The parameters supplied for formatting the string do not match the specified parameters.

Invalid order of method invocation in heredoc RB-LI1026
Bug risk
Major
Autofix

Methods on a heredoc should be invoked at beginning, not at the end.

Interpolation in a single-quote string RB-LI1030
Bug risk
Major

Interpolations do not work in single-quote strings. Double quotes must be used.

while/until detected in begin block RB-LI1033
Bug risk
Major

while/until should be used at the beginning of the block, and without the begin statement.

Multiple comparison detected RB-LI1035
Bug risk
Major
Autofix

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.

Empty interpolation detected RB-LI1018
Bug risk
Major
Autofix

Rails.env predicate does not exist RB-RL1056
Bug risk
Major

Environments 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.

Unused block argument detected RB-LI1073
Bug risk
Minor
Autofix

If an unused block argument is intended, it should be prefixed with an underscore.

Trailing comma in attribute declaration detected RB-LI1099
Bug risk
Major

Leaving a trailing comma in attribute declarations, such as #attr_reader will nullify the next method definition by overriding it with a getter method.

Possible unintended string concatenation RB-LI1027
Bug risk
Major

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.

Function argument overwritten before use RB-LI1064
Bug risk
Major

A function argument is shadowed. It is usually a result of a typo.

Detected == for comparison instead of recommended equal? method RB-LI1100
Bug risk
Major

Prefer 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.