Skip to content

Commit

Permalink
[Fix #336] Expand the safety warning on Performance/Detect
Browse files Browse the repository at this point in the history
In addition to the external library activerecord, the built in Hash
class also has compatibility issues.
  • Loading branch information
ekohl committed Jan 26, 2023
1 parent a28bd39 commit 83b47e3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rubocop/cop/performance/detect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ module Performance
# `detect` instead.
#
# @safety
# This cop is unsafe because is has known compatibility issues with `ActiveRecord` and other
# frameworks. `ActiveRecord` does not implement a `detect` method and `find` has its own
# meaning. Correcting `ActiveRecord` methods with this cop should be considered unsafe.
# This cop is unsafe because is assumes the class implements the
# `Enumerable` interface, but can't reliably detect this. This creates
# known compatibility issues with `Hash`, `ActiveRecord` and other
# frameworks. `Hash` and `ActiveRecord` do not implement a `detect`
# method and `find` has its own meaning. Correcting `Hash` and
# `ActiveRecord` methods with this cop should be considered unsafe.
#
# @example
# # bad
Expand Down

0 comments on commit 83b47e3

Please sign in to comment.