Skip to content

Commit

Permalink
[Fix rubocop#1283] Mark WhereRange as unsafe autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Jun 7, 2024
1 parent 07bec34 commit f4a9f1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/change_where_range_unsafe_autocorrect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1283](https://github.com/rubocop/rubocop-rails/issues/1283): Mark `WhereRange` as unsafe autocorrect. ([@fatkodima][])
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ Rails/WhereRange:
Description: 'Use ranges in `where` instead of manually constructing SQL.'
StyleGuide: 'https://rails.rubystyle.guide/#where-ranges'
Enabled: pending
SafeAutoCorrect: false
VersionAdded: '2.25'

# Accept `redirect_to(...) and return` and similar cases.
Expand Down
5 changes: 5 additions & 0 deletions lib/rubocop/cop/rails/where_range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ module Rails
# Identifies places where manually constructed SQL
# in `where` can be replaced with ranges.
#
# @safety
# This cop's autocorrection is unsafe because it can change the query
# by explicitly attaching the column to the wrong table. For example, if using
# joins and the referenced column is from the joined table.
#
# @example
# # bad
# User.where('age >= ?', 18)
Expand Down

0 comments on commit f4a9f1b

Please sign in to comment.