Gradualizer icon indicating copy to clipboard operation
Gradualizer copied to clipboard

Gradualizer results from top 24 Hex.pm Erlang libraries

Open erszcz opened this issue 2 years ago • 4 comments

I've run Gradualizer using the Rebar3 plugin on the top Hex.pm Erlang libs and here are the results. The log is more than 4000 lines long. I consider this another source of feedback on Gradualizer's fit for practical use. Some very general conclusions so far:

  • not a single Gradualizer crash - we're already very robust
  • there's plenty of can't find include file warnings; most likely due to incomplete non-otp-libraries repo setup, so it could use a bit more work on that front
  • type errors are quite common in community projects :)

Some examples of the last point follow. For example, a typo in a spec in meck:

/Users/erszcz/work/erszcz/non-otp-libraries/apps/meck/src/meck.erl: The function call on line 352 at column 5 is expected to have type [{atom(), atom(), 0..255}] but it has type [{atom(), atom(), byte}]

      ExcludePassthrough :: boolean().
expects(Mod, ExcludePassthrough) when is_atom(Mod) ->
    meck_proc:list_expects(Mod, ExcludePassthrough);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Confusion between binary() and bitstring() in hpack:

/Users/erszcz/work/erszcz/non-otp-libraries/apps/hpack_erl/src/hpack.erl: The bit expression on line 124 at column 8 is expected to have type <<_:8, _:_*8>> but it has type <<_:1, _:_*1>>

%% First bit is '1', so it's an 'Indexed Header Feild'
%% http://http2.github.io/http2-spec/compression.html#rfc.section.6.1
decode(<<2#1:1,_/bits>>=B, HeaderAcc, Context) ->
       ^^^^^^^^^^^^^^^^

erszcz avatar Sep 26 '22 17:09 erszcz

Some more info:

20:11:05 erszcz @ x6 : ~/work/erszcz/non-otp-libraries (gradualizer %)
$ tokei
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 AsciiDoc                4          428          295            0          133
 BASH                    2          178          114           20           44
 C++                     3         2524         1933          267          324
 C++ Header              4         1209          913          146          150
 CSS                     1          144          118            2           24
 D                       3            8            8            0            0
 Dockerfile              1           27           21            0            6
 Elixir                 15         3671         3189           20          462
 Erlang                407       195776       163175        20743        11858
 Makefile               13        30950        25069         1029         4852
 Protocol Buffers        1           81           56           12           13
 Shell                   5          107           80           14           13
 Plain Text              3           45            0           42            3
 XML                     5           46           42            4            0
-------------------------------------------------------------------------------
 Markdown               30         4793            0         3427         1366
 |- BASH                 2           10            5            3            2
 |- Elixir               4          350          258           53           39
 |- Erlang              16          917          818           45           54
 |- Shell                2            3            3            0            0
 |- XML                  1          184          163            7           14
 (Total)                           6257         1247         3535         1475
===============================================================================
 Total                 497       239987       195013        25726        19248
===============================================================================

Literally one Gradualizer timeout warning:

$ grep "Timeout checking function" gradualizer.noansi.log | wc -l
       1

erszcz avatar Sep 26 '22 18:09 erszcz

Nice!

Running on beams rather than erls would probably eliminate the include not found errors. Have you tried?

zuiderkwast avatar Sep 27 '22 09:09 zuiderkwast

I just ran rebar3 gradualizer without looking under the hood this time. I think it runs on the beams, but maybe it needs an extra flag. Good point to check, though.

erszcz avatar Sep 27 '22 11:09 erszcz

OK. If it's running on erls, it should be able to access to the include dirs defined in the rebar config too. I guess there are more potential improvements in the rebar plugin.

zuiderkwast avatar Sep 27 '22 11:09 zuiderkwast