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

question
lint

#1

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

Thanks!


#2

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


#3

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


#4

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


#5

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")

#6

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.


#7

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

EDIT: I see it as well.


#8

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


#9

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