You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two reasons why this is an unreliable solution:
it doesn't know about things that have yet to be autoloaded
it's non-deterministic with regards to Garbage Collection of classes. If you use Class.descendants in Test, where there is a pattern to dynamically define classes, GC is unpredictable for when those classes are cleaned up and removed by the GC.
It seems like all attempts to get a cop like this into RuboCop itself have been declined, as have attempts to document the risks have stalled. Closing as it doesn't feel right for a GitHub custom cop that we can never upstream but is a language-specific thing rather than a GitHub-specific thing.
Activity
[-]Avoid usage of `Class.descendents`[/-][+]New Cop: Avoid usage of `Class.descendents`[/+]alexanderadam commentedon Oct 21, 2025
Is this still relevant with AS's
DescendantsTrackerand the removal of the Ruby implementation?bensheldon commentedon Oct 21, 2025
Yes. The reasons for not using 'descendants' are still valid regardless of how
descendantsis implemented.Edit: oh sorry, didn't see this was the GitHub rubocop 🖖🏻
issyl0 commentedon Jul 15, 2026
It seems like all attempts to get a cop like this into RuboCop itself have been declined, as have attempts to document the risks have stalled. Closing as it doesn't feel right for a GitHub custom cop that we can never upstream but is a language-specific thing rather than a GitHub-specific thing.