Skip to content

Commit

Permalink
[select-last-with-arguments]
Browse files Browse the repository at this point in the history
Don't add offense if .last is called with arguments in the same vein as .first change for 0.10.1
  • Loading branch information
pdsmcgavin committed Sep 25, 2023
1 parent e6e2f62 commit 6760318
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fasterer/scanners/method_call_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def check_last_offense

case method_call.receiver.name
when :select
return if method_call.arguments.count > 0

add_offense(:select_last_vs_reverse_detect)
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/support/analyzer/25_select_last_vs_reverse_detect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ def slow
def fast
ARRAY.reverse.detect { |x| (x % 10).zero? }
end

ARRAY.select { |x| (x % 10).zero? }.last(5)

0 comments on commit 6760318

Please sign in to comment.