rubocop / rubocop-rails

A RuboCop extension focused on enforcing Rails best practices and coding conventions.
https://docs.rubocop.org/rubocop-rails
MIT License
808 stars 261 forks source link

WhereRange doesn't suggest corrections for <= comparisons #1312

Closed vrodic closed 2 weeks ago

vrodic commented 3 months ago

With string where queries like where("starts_at <= :ends_at", ends_at: ends_at.end_of_day) the WhereRange cop doesn't suggest changing this to where(starts_at: ..ends_at.end_of_day)


RuboCop version

$ [bundle exec] rubocop -V
1.65.0 (using Parser 3.3.4.0, rubocop-ast 1.31.3, running on ruby 3.2.2) [x86_64-linux]
  - rubocop-minitest 0.35.1
  - rubocop-performance 1.21.1
  - rubocop-rails 2.25.1
koic commented 3 months ago

I'd like to know more about the context. Are you referring to a case where join is used with where("starts_at <= :ends_at", ends_at: ends_at.end_of_day) to perform table joins?

koic commented 3 months ago

I'm wondering if this point about Safety section is already mentioned in the documentation: https://docs.rubocop.org/rubocop-rails/2.25/cops_rails.html#railswhererange

koic commented 2 weeks ago

As there hasn't been any activity for a while, I will close this issue. Please feel free to reopen it with further details.