Skip to content

Commit

Permalink
Merge pull request #103 from pdsmcgavin/select-last-with-arguments
Browse files Browse the repository at this point in the history
[select-last-with-arguments]
  • Loading branch information
DamirSvrtan committed Nov 20, 2023
2 parents 9ebf505 + 6760318 commit 58c309b
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
Expand Up @@ -157,6 +157,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
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 58c309b

Please sign in to comment.