Skip to content

Commit

Permalink
Fix symbol to proc offense detector when a method is invoked on a ran…
Browse files Browse the repository at this point in the history
…ge or array

Fixes the following issue: #77. Happens when somebody invokes a method with no args on an array or range in a block. Example in the spec.
  • Loading branch information
DamirSvrtan committed Feb 5, 2020
1 parent 7a6d4d4 commit 1a66130
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
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 @@ -132,6 +132,7 @@ def check_symbol_to_proc
return unless body_method_call.arguments.count.zero?
return if body_method_call.has_block?
return if body_method_call.receiver.nil?
return if body_method_call.receiver.is_a?(Fasterer::Primitive)
return if body_method_call.receiver.name != method_call.block_argument_names.first

add_offense(:block_vs_symbol_to_proc)
Expand Down
4 changes: 4 additions & 0 deletions spec/support/analyzer/18_block_vs_symbol_to_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
puts route.name
end

route_sets.each do |routes|
[].finalize!
end

route_sets.each(&:finalize!)

route_sets.each(:oppa) do |route|
Expand Down

0 comments on commit 1a66130

Please sign in to comment.