tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Generated activesupport rbi does not include String#starts_with? & String#ends_with?

Open thomasdziedzic-census opened this issue 4 years ago • 3 comments

ActiveSupport implements starts/ends_with? methods as aliases on the String class.

When generating an rbi file via tapioca for activesupport, it doesn't generate the aliased methods in the rbi file.

https://github.com/rails/rails/blob/v6.0.4.1/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb

I did try to fix it by adding require 'active_support/core_ext/string' to my require.rb file, and running bin/tapioca gem --all but that didn't generate the missing methods either.

thomasdziedzic-census avatar Nov 30 '21 16:11 thomasdziedzic-census

Note: this is happening because we filter out methods without a source location. The lack of location may be because those methods are aliases declared with alias_method.

Morriar avatar Jul 06 '22 21:07 Morriar

👋 Thanks for opening this issue - we ran into this exact issue. I'm happy to take a look at updating the filter to account for aliased methods if that sounds reasonable to you all?

ipc103 avatar Oct 05 '23 18:10 ipc103

@ipc103 I think you can have a breakpoint in https://github.com/Shopify/tapioca/blob/5a913bc44e00c97fb5f0e81a27c819a899f4a1b3/lib/tapioca/gem/listeners/methods.rb#L71 and try to follow an aliased method. It might be easier to add a test that contains a gem code that reopens String and defines an alias method (e.g. https://github.com/Shopify/tapioca/blob/5a913bc44e00c97fb5f0e81a27c819a899f4a1b3/spec/tapioca/cli/gem_spec.rb#L273)

KaanOzkan avatar Oct 06 '23 18:10 KaanOzkan