tonyhffong / Lint.jl

A lint tool for Julia code
Other
168 stars 33 forks source link

Check for unused keyword arguments #270

Open jonniedie opened 4 years ago

jonniedie commented 4 years ago

Only positional arguments are currently checked. It might also be worth adding an extra stern warning for unused keyword argument slurps, because they can cause silent failures on misspelled keyword arguments:

julia> badfun(;some_arg=1, another_arg=2, kwargs...) = some_arg*another_arg^2
badfun (generic function with 1 method)

julia> badfun(;another_arg=5)
25

julia> badfun(;anotherarg=5)
4

julia> betterfun(;some_arg=1, another_arg=2) = some_arg*another_arg^2
betterfun (generic function with 1 method)

julia> betterfun(;another_arg=5)
25

julia> betterfun(;anotherarg=5)
ERROR: MethodError: no method matching betterfun(; anotherarg=5)
Closest candidates are:
  betterfun(; some_arg, another_arg) at REPL[2]:1 got unsupported keyword argument "anotherarg"
Stacktrace: ...