ecomba / vim-ruby-refactoring

Refactoring tool for Ruby in vim!
520 stars 52 forks source link

RExtractMethod passes in block variables when the block is entirely within the extracted block #27

Open tcrayford opened 13 years ago

tcrayford commented 13 years ago

Inside the following method:

def validate(numbers)
  bar = 1
  numbers.any? do |n|
    n < 0
  end
end

,with

numbers.any? do |n| n < 0 end

When I do extract method, and give the new method a name of "check_numbers", I get the following:

def check_numbers(n,numbers)
  numbers.any? do |n|
    n < 0
  end
end

def validate(numbers)
  bar = 1
  check_numbers(n,numbers)
end

Instead, I expect:

def validate(numbers)
  bar = 1
  check_numbers(numbers)
end

def check_numbers(numbers)
  numbers.any? do |n|
    n < 0
  end
end
tcrayford commented 13 years ago

Note that the temp is needed here, without it, the refactoring works as expected.

nrocy commented 13 years ago

Cheers Tom, I'll take a look at this one