`tapioca gem` misses sig for module_function methods of the class variety
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
When generating sorbet/rbi/gems/code_ownership@1.37.0.rbi with tapioca gem code_ownership module_function defined methods will be created without signatures.
# Gemfile
source "https://rubygems.org"
gem 'tapioca', require: false, :group => [:development, :test]
gem "code_ownership", "1.37.0"
Specifically
# code_ownership.rb
module CodeOwnership
module_function
sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }
def for_class(klass); end
end
will be turned into
# code_ownership.rbi
module CodeOwnership
sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }; def for_class(klass); end
class << self
def for_class(klass); end
end
end
should be turned into
# code_ownership.rbi
module CodeOwnership
sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)); def for_class(klass); end
class << self
sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }; def for_class(klass); end
end
end
OR
# code_ownership.rbi
module CodeOwnership
module_function
sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }; def for_class(klass); end
end
I tried testing this in the rbi gem but it correctly parsed the module to the last one above
I'll gladly dive into the code to fix this if somebody could point out where this is an issue. I did some code diving as you can see already but I'm a bit lost where
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generated sorbet/rbi/gems/code_ownership@1.37.0.rbi output with tapioca gem code_ownership, using the code_ownership.rb module_function example. Trace Tapioca's gem RBI generation and compare it with the rbi gem's parsing behavior; done means the generated RBI retains the signature for both the instance and singleton method, or uses module_function as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100