ericphanson / ExplicitImports.jl

Developer tooling for Julia namespace management: detecting implicit imports, improper explicit imports, and improper qualified accesses
https://ericphanson.github.io/ExplicitImports.jl/
MIT License
62 stars 2 forks source link

Detect improper self-qualified names #55

Closed fredrikekre closed 2 weeks ago

fredrikekre commented 1 month ago

Sometimes you see "self-qualified" names like e.g.

module A

f() = #...

g() = A.f()

end

This usually comes from prototyping code outside the module and then forgetting to remove the A. when putting it inside.

It would be great to have a check for this! It might be a little out of scope but I think this could be qualified as a "improper qualification" which already is included here. In any case I would assume the code to detect this is basically already there. Thoughts?

ericphanson commented 1 month ago

Hm, yeah, I agree this could make sense as an "improper" qualified access. I think it would have to be a new check_ function, since it seems out of scope for check_all_qualified_accesses_via_owners (and I don't want non-breaking releases of ExplicitExports to start failing folks' tests or CI runs), but that's alright.

It would indeed to be easy to add, since we have access to both the qualifying module and the module the name is in, so we can just check if they are == (namely, current_mod and mod in here)

fredrikekre commented 2 weeks ago

Thanks!