Ruby

Ruby

Made by DeepSource
Use lambda/proc instead of a plain method call RB-RL1052
Anti-pattern
Major

Scope calls should not pass a method (usually a scope) instead of a lambda/proc.

Use of BEGIN block detected RB-ST1009
Anti-pattern
Minor

BEGIN blocks should not be used.

Enum detected with array syntax RB-RL1018
Anti-pattern
Major
Autofix

When using array syntax, adding an element in a position other than the last causes all previous definitions to shift. Explicitly specifying the value for each key prevents this from happening.

Inconsistent usage of request attribute detected RB-RL1047
Style
Major
Autofix

The referer from the request object should be accessed in a consistent way throughout the codebase. By default, this issue is raised when referrer is used. However, it can be configured to raise this issue on usage of referer in .rubocop.yml.

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.

Use start_with in place of regex RB-PR1021
Performance
Major

If a regex only checks if the string starts with a particular string, String#start_with? can be used as a simpler and more efficient method.

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.

Use Array.new() with a block instead of .times RB-PR1023
Performance
Major

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.

Ineffective access modifier detected RB-LI1028
Anti-pattern
Major

private or protected access modifiers which are applied to a singleton method do not make them private/protected. private_class_method can be used for that.

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

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

Literal used in interpolation RB-LI1032
Anti-pattern
Major
Autofix

Literals used in interpolations are pointless, and can be replaced by the literal directly.

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.