esl / gradient

Gradient is a static typechecker for Elixir
Apache License 2.0
437 stars 13 forks source link

139 warn missing spec flags #141

Closed zofpolkowska closed 1 year ago

zofpolkowska commented 1 year ago

Add flags for enabling missing specs detection:

erszcz commented 1 year ago

This looks good, but I'm experiencing some issues when running on example projects.

First example is https://github.com/esl/MongoosePush/tree/gradient - when running mix gradient --warn-missing-spec on that branch I get:

Typechecking files...
src/APNS-Topics.erl: Call to undefined function :APNS-Topics.module_info/1 on line 74 at column 16
** (ArgumentError) argument error
    :erlang.--([:encode], nil)
    (gradient 0.1.0) lib/gradient/elixir_checker.ex:164: Gradient.ElixirChecker.warn_missing_spec/2
    (gradient 0.1.0) lib/gradient/elixir_checker.ex:94: Gradient.ElixirChecker.check_spec/2
    (gradient 0.1.0) lib/gradient.ex:75: Gradient.handle_elixir_ast/2
    (elixir 1.13.1) lib/enum.ex:1593: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.13.1) lib/stream.ex:572: anonymous fn/4 in Stream.map/2
    (elixir 1.13.1) lib/enum.ex:4475: Enumerable.List.reduce/3
    (elixir 1.13.1) lib/stream.ex:1719: Enumerable.Stream.do_each/4

I rechecked on gradient/examples/simple_app and it seems I get a different instance of the same issue:

** (ArgumentError) argument error
    :erlang.--(nil, nil)
    (gradient 0.1.0) lib/gradient/elixir_checker.ex:164: Gradient.ElixirChecker.warn_missing_spec/2
    (gradient 0.1.0) lib/gradient/elixir_checker.ex:94: Gradient.ElixirChecker.check_spec/2
    (gradient 0.1.0) lib/gradient.ex:75: Gradient.handle_elixir_ast/2
    (elixir 1.13.1) lib/enum.ex:1593: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.13.1) lib/stream.ex:572: anonymous fn/4 in Stream.map/2
    (elixir 1.13.1) lib/enum.ex:4475: Enumerable.List.reduce/3
    (elixir 1.13.1) lib/stream.ex:1719: Enumerable.Stream.do_each/4

@zofpolkowska, could you look into it?