# Any way to tell if there is any variable defined but not used?

**URL:** <https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114>\
**Category:** New to Julia\
**Tags:** question, lint\
**Created:** [December 23, 2016, 11:36am UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114 "2016-12-23T11:36:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [December 23, 2016, 11:36am UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/1 "2016-12-23T11:36:33Z")

</div>

Is there a tool like in Matlab that can tell if any defined variables are not used at all?

Thanks!

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [December 23, 2016, 12:07pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/2 "2016-12-23T12:07:06Z")

</div>

Maybe the [Lint.jl](https://lintjl.readthedocs.io/en/stable/) package is what you are looking for?

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [December 23, 2016, 2:26pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/3 "2016-12-23T14:26:35Z")

</div>

Wow, this is exactly what I’m looking for. Thanks!!

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [December 24, 2016, 4:15pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/4 "2016-12-24T16:15:35Z")

</div>

I’m trying to call `lintpkg` and it throws the following error

```julia
julia> lintpkg("FastSum")
ERROR: "cannot find path: /home/calvin/.julia/v0.5/FastSum/src/FastSum.jl"
 in #lintpkg#87(::Void, ::Function, ::String) at /home/calvin/.julia/v0.5/Lint/src/Lint.jl:52
 in lintpkg(::String) at /home/calvin/.julia/v0.5/Lint/src/Lint.jl:45

```

This is a package/module that I wrote by myself. What might be the cause of this error? Thanks!!

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [December 24, 2016, 4:36pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/5 "2016-12-24T16:36:51Z")

</div>

Is the module in the directory `/home/calvin/.julia/v0.5/FastSum/src/FastSum.jl`?  
Otherwise, if it is in another directory, you should set `LOAD_PATH` to point to the place where the module is:

```julia
push!(LOAD_PATH, "path/to/my/package")

```

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [December 24, 2016, 5:25pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/6 "2016-12-24T17:25:22Z")

</div>

Thanks for the hint.

The actual code for the module is not in `/home/calvin/.julia/v0.5/FastSum/src/FastSum.jl` and the location of the actual code is included in the current path. That’s why I’m puzzled.

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [December 24, 2016, 5:41pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/7 "2016-12-24T17:41:26Z")

</div>

Did you try to `push!` the current path into `LOAD_PATH`? Modules are only loaded from `LOAD_PATH`.

EDIT: I see it as well.

---

<div class="post-metadata">

**Author:** ![fengyang.wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fengyang.wang/32/104_2.png) [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Post date:** [April 13, 2017, 4:24am UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/8 "2017-04-13T04:24:27Z")

</div>

Lint.jl currently does not respect LOAD\_PATH. This is a known bug.

[https://github.com/tonyhffong/Lint.jl/issues/168](https://github.com/tonyhffong/Lint.jl/issues/168)

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [April 14, 2017, 2:22pm UTC](https://discourse.julialang.org/t/any-way-to-tell-if-there-is-any-variable-defined-but-not-used/1114/9 "2017-04-14T14:22:20Z")

</div>

Maybe you are interested [linter-julia](https://atom.io/packages/linter-julia) in Atom editor ([Juno](http://junolab.org)).
