Add --report-orphans flag to produce orphan definition report#566
Merged
Add --report-orphans flag to produce orphan definition report#566
--report-orphans flag to produce orphan definition report#566Conversation
Morriar
reviewed
Feb 6, 2026
--show-orphan flag to produce orphan definition report--report-orphans flag to produce orphan definition report
vinistock
reviewed
Feb 6, 2026
rust/rubydex/src/model/graph.rs
Outdated
|
|
||
| /// Walks the Name system's `parent_scope` chain to reconstruct the constant path. | ||
| /// Falls back to `nesting` for enclosing scope context when there is no explicit parent scope. | ||
| pub(crate) fn build_qualified_name_from_name(&self, name_id: NameId) -> String { |
Member
There was a problem hiding this comment.
Not a strong opinion, but I would probably simplify the code and only keep URI + line/col information. That way, whoever is investigating the inconsistent data can open the file in one click and take a look at what pattern causes it.
Member
Author
There was a problem hiding this comment.
I still think it'd helpful to have the type and name. The collision cases were found because the generated FQN was weird. If all we have is the location, then we wouldn't be able to tell they became orphan because of the name collision.
vinistock
approved these changes
Feb 9, 2026
Add a CLI flag that writes a TSV report of all orphan definitions (definitions not linked to any declaration) to a specified file. Each line contains: kind, qualified name, and source location. The qualified name is reconstructed by walking either the Name system's parent_scope chain (for constant-like definitions) or the lexical_nesting_id chain (for method-like definitions). Ungate Offset#to_display_range so it can be reused for location formatting outside of tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When used, rubydex would list orphan definitions under
/tmp/rubydex-orphan-report.txt(can be changed by supplying arg to the flag).Example output:
This feature is helpful for investigating issues.
For example, some definitions in Core become orphan due to(This is fixed now)NameIdcollision and that's shown in the report (I've shown that to @vinistock in pairing).Another example is that this helps me investigate incorrect resolution in #515.
However, it's also worth noting that detecting orphans don't necessarily mean there's a but in the code or rubydex. For example, due to the lack of
<main>representation, top level instance variables would be considered orphans now.