# Is there a way to easily identify useless import, export and using statements

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580>\
**Category:** General Usage\
**Created:** [September 21, 2022, 3:20pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580 "2022-09-21T15:20:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atiyah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atiyah/32/46462_2.png) [@Atiyah](https://discourse.julialang.org/u/Atiyah)\
**Post date:** [September 21, 2022, 3:20pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/1 "2022-09-21T15:20:59Z")

</div>

I was wondering if there is a way (probably a tool or a package) that could show whether an import, an export or a using statement is useless in a particular source file. Particularly,

```julia
using X: Type1, Type2, foo1, foo2 # are these really used?
import Y: Type3, zee1, zee2 # are these really extended here
export Type3, gaa1, gaa2, # are these still there

```

Something like that would be great for maintaining the set of employed, extended and exported modules, types and functions in an incremental development process.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [September 21, 2022, 3:27pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/2 "2022-09-21T15:27:11Z")

</div>

Related:

> [@Tool to tell if a package has unused dependencies or using unused packages](https://discourse.julialang.org/t/tool-to-tell-if-a-package-has-unused-dependencies-or-using-unused-packages/36254/11):
>
> Sorry to resurrect this old topic but I noted a corner case: Imagine that in MyPkg.jl I do a using Printf: @printf then julia\> isdefined(MyPkg,:Printf) false and the remove would incorrectly (at least to me) suggest to remove Printf. Any way to programmatically check for unused deps?

I don’t think that it is possible to detect “useless” `export`s, though. Exported symbols are meant to be used by “others”, not by the source.

---

<div class="post-metadata">

**Author:** ![Atiyah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atiyah/32/46462_2.png) [@Atiyah](https://discourse.julialang.org/u/Atiyah)\
**Post date:** [September 21, 2022, 3:50pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/3 "2022-09-21T15:50:02Z")

</div>

> [@heliosdrm](#):
>
> I don’t think that it is possible to detect “useless” `export`s, though. Exported symbols are meant to be used by “others”, not by the source.

Here I mean exports that are neither defined nor implemented.

Edit: I noticed that the package Aqua.jl apparently does that

Edit2: Please let me know if I should delete this thread?

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [September 21, 2022, 4:07pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/4 "2022-09-21T16:07:09Z")

</div>

> [@Atiyah](#):
>
> Please let me know if I should delete this thread?

No, don’t delete it; it will increase the chances for another person with the same problem to find the solution. If you think that it is solved, what you can do is to mark the corresponding answer as “Solution”, so that it will be more visible to other readers.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [September 21, 2022, 9:33pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/5 "2022-09-21T21:33:20Z")

</div>

> [@Atiyah](#):
>
> I mean exports that are neither defined nor implemented.

Isn’t a warning issued in these cases?

---

<div class="post-metadata">

**Author:** ![Atiyah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atiyah/32/46462_2.png) [@Atiyah](https://discourse.julialang.org/u/Atiyah)\
**Post date:** [September 22, 2022, 7:14am UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/6 "2022-09-22T07:14:39Z")

</div>

> [@sylvaticus](#):
>
> Isn’t a warning issued in these cases?

Apparently no

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [September 22, 2022, 8:16am UTC](https://discourse.julialang.org/t/is-there-a-way-to-easily-identify-useless-import-export-and-using-statements/87580/7 "2022-09-22T08:16:08Z")

</div>

> [@Atiyah](#):
>
> Please let me know if I should delete this thread?

Threads should almost never be deleted. There would have to be strong reasons, and even though you can delete your own posts, you cannot delete a thread yourself.

If a thread simply isn’t very useful, it will just quietly sink to the bottom of the front page, and eventually be forgotten.
