Skip to content

Commit

Permalink
Fix select first with arguments vs detect
Browse files Browse the repository at this point in the history
  • Loading branch information
DamirSvrtan committed Mar 14, 2023
1 parent a15d10d commit 2b8728a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.10.1

- There has been a [bug report #99](https://github.com/DamirSvrtan/fasterer/issues/99) that the `select_first_vs_detect` reports false positives when first gets an argument passed in. If there is an argument passed in, the detect method is not suitable, since it always returns the first element matching (can't return multiple items).

## 0.10.0

- Due to issues while setting up builds with Github Actions, I have dropped Ruby 2.2 support. It's EOL date was 2018-03-31, and I don't have the bandwidth to support deprecated Ruby versions. The only reason at this point why Ruby versions 2.3, 2.4 and 2.5 are supported is because they still work with other dependencies, so it's no effort currently to support them. Once they become issues, they'll probably be dropped.
Expand Down
1 change: 1 addition & 0 deletions lib/fasterer/scanners/method_call_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def check_first_offense
add_offense(:shuffle_first_vs_sample)
when :select
return unless method_call.receiver.has_block?
return if method_call.arguments.count > 0

add_offense(:select_first_vs_detect)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fasterer/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Fasterer
VERSION = '0.10.0'
VERSION = '0.10.1'
end
2 changes: 2 additions & 0 deletions spec/support/analyzer/12_select_first_vs_detect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
ARRAY.select(&:zero?).first

ActiveRecordRelation.new.select('name').first

ARRAY.select { |x| x.eql?(15) }.first(5)

0 comments on commit 2b8728a

Please sign in to comment.