Rails' ActiveRecord ORM allows you to search a model using its attributes, however if you provide an attribute that doesn't exist on a model, it will throw an
Rails expects the route to match an existing action (method) in the specified controller. If the method doesn't exist, Rails won't be able to execute it and will raise an error. This is to ensure that you have defined all the necessary actions in your controller and that your routes accurately reflect the available actions.
If you add an association to an ActiveRecord model that doesn't define a reference in the migration, you may encounter errors when trying to perform certain operations on the model or when accessing associated data.
IO.selectwith single argument detected RB-DS1003
IO.select statements can get very hard to make them compatible with Ruby 3 scheduler. It is recommended to use
wait_writable on an
IO object with a given timeout instead of rescuing an
IO::WaitWritable error and using
IO.select in the block.
If an unused method argument is intended, it should be prefixed with an underscore.
While the safe navigation operator is generally a good idea, when checking
foo&.blank? in a conditional, foo being
nil will actually do the opposite of what was intended.
Requiring, or relatively requiring same file/module twice is unnecessary and either of the blocks can be removed as they both serve the same purpose.
When creating a custom value object using
Struct.new, be careful as to not have attributes whose names match the built-in methods provided by the
Range literal should be enclosed in parentheses when the end of the range is at a line break, otherwise the intention of the code becomes ambigous.
Do not return from an
ensure block. If you explicitly return from a method inside an ensure block, the return will take precedence over any exception being raised, and the method will return as if no exception had been raised
You intended to write as
rescue StandardError. However, you have written
rescue => StandardError. In that case, the result of
rescue will overwrite
Lambda without a literal block is deprecated since Ruby 3.0, use the
Non-atomic file operations can cause problems that are difficult to reproduce, especially in cases of frequent file operations in parallel, such as test runs with parallel_rspec.
uniqueness: trueused on a field that is not an index RB-W1022
uniqueness: true on an ActiveRecord model can be error prone if the column hasn't been declared unique at the
Starting from Ruby 3.1,
prepend must not be used within a
refine block. These methods are deprecated and should be replaced with
Having duplicate magic comments can lead to potential bug-risks, as a duplicate magic comment can have a different argument passed to it which can change the behavior of the program or even cause it to crash.
Arel::Tablecolumn reference RB-W1018
Avoid using "*" on an
Arel::Table column reference.
Setting the timezone using
Time.zone= should be avoided.