Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise when the :singleton-method: directive can't extract the name? #364

Closed
p8 opened this issue Jan 24, 2024 · 2 comments
Closed

Raise when the :singleton-method: directive can't extract the name? #364

p8 opened this issue Jan 24, 2024 · 2 comments

Comments

@p8
Copy link
Member

p8 commented Jan 24, 2024

The :singleton-method: directive can't extract the name of accessors defined with singleton_class.attr_accessor :name.
Instead the method name will be set to unknown, see: rails/rails#50836

RDoc will show a warning if the method can't be extracted when RDoc is run in verbose mode.
But maybe this should raise an error instead?

Examples of warnings when running RDoc on Rails:

...
Duplicate method ActiveRecord::unknown in file activerecord/lib/active_record.rb
activerecord/lib/active_record.rb:457:18: unknown name token #<struct RDoc::Parser::RipperStateLex::Token line_no=457, char_no=17, kind=:on_period, text=".", state=DOT> for meta-method 'singleton_class'
Duplicate method ActiveRecord::unknown in file activerecord/lib/active_record.rb
activerecord/lib/active_record.rb:487:18: unknown name token #<struct RDoc::Parser::RipperStateLex::Token line_no=487, char_no=17, kind=:on_period, text=".", state=DOT> for meta-method 'singleton_class'
Duplicate method ActiveRecord::unknown in file activerecord/lib/active_record.rb
Duplicate method ActiveRecord::Coders::YAMLColumn::SafeCoder#dump in file activerecord/lib/active_record/coders/yaml_column.rb
Duplicate method ActiveRecord::Coders::YAMLColumn::SafeCoder#load in file activerecord/lib/active_record/coders/yaml_column.rb
Duplicate method ActiveRecord::LogSubscriber#query_source_location in file activerecord/lib/active_record/log_subscriber.rb
...

The duplicate method warnings are for methods defined separately for different Ruby versions.

Or maybe we should have a lint task?

@zzak
Copy link
Member

zzak commented May 24, 2024

There isn't really an RDoc linter afaik, I think making it configurable to raise that we can run with --dry-run in another job to get the same effect

@zzak
Copy link
Member

zzak commented Nov 1, 2024

This is a feature I think we should be discussing in rdoc. I'd be happy to see this though 👍

@zzak zzak closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants