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

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

Thanks!

Maybe the Lint.jl package is what you are looking for?

3 Likes

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

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

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!!

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:

push!(LOAD_PATH, "path/to/my/package")
1 Like

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.

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

EDIT: I see it as well.

Lint.jl currently does not respect LOAD_PATH. This is a known bug.

https://github.com/tonyhffong/Lint.jl/issues/168

Maybe you are interested linter-julia in Atom editor (Juno).

1 Like