Closed milmazz closed 4 years ago
@milmazz in thinking through this further, I'd be interested in your take on what considerations should be factored in here.
Specifically, tokens across all apps (e.g. app1
and app2
) will be present in the tags file being used for identifying tokens within e.g. app2
. If app2
references a token once from app1
, I think it'd register as unused if there was a single occurrence in the app where unused
was run.
This doesn't seem ideal, but I'd defer to you as you'd mentioned running in a child rather than in the root.
Specifically, tokens across all apps (e.g.
app1
andapp2
) will be present in the tags file being used for identifying tokens within e.g.app2
.
Yes, the tags
are shared among all the applications in the umbrella app.
If
app2
references a token once fromapp1
, I think it'd register as unused if there was a single occurrence in the app whereunused
was run.This doesn't seem ideal
Sadly this is the case for mix xref callers
at the moment in an umbrella project, I mention this because I tend to use mix xref callers
as a way to confirm the unused functions found by unused
.
But I agree with you, that behavior is not ideal, I think that unused
should consider all the tokens when it's trying to find unused functions, but for presentational purposes, in this case, it should only display unused functions in the current child.
@milmazz I've got a pass of this working on https://github.com/unused-code/unused_rs/tree/rev-parse.
This only uses git rev-parse --git-dir
to calculate the correct path for .git/tags
, but I'm wondering now if it also makes sense to do relative path traversal to look for tags
and tmp/tags
the same way.
So, in this linked branch, it'll join the "rev-parse"d path with tags
, resulting in APP_ROOT/.git/tags
– I'm wondering if we should also join "../tags"
and "../tmp/tags"
to ensure we're looking in the right spot (relative to .git
) if the tags file doesn't live in .git
. Any thoughts?
@milmazz another note – while this branch does correctly determine the .git
path, it does not filter results down to those that occur within the current directory. I'd be interested in seeing some real-world use cases or digging into this further before exploring this, as I'm guessing there will be a fair amount of lift to filter results based on the cwd.
This should be resolved via 1f0ea1d613f25da980ff70768442a8e569c89dd4; thanks for your patience @milmazz!
Using the Default config setting,
unused-rs
(and alsounused
) failed to find the ctags file in an umbrella project, specifically if you run the command under a specific app.How to reproduce
unused-rs
works at the root of the umbrella project:but it doesn't work when you try the same command in a specific app:
I think that
unused-rs
should rely in something likegit rev-parse --git-dir
to discover the path to the.git
directory, this should also work when you're inside specific apps in an umbrella project:BTW, I noticed the same behavior on
unused
: