eqwalizer WhatsApp 开源的erlang类型检查工具

可能大家都听说过WhatsApp 对于erlang 使用是比较多的,WhatsApp 的IM 系统就是基于erlang 开发的,同时WhatsApp 也开源了
一些erlang周边的工具eqwalizer 是一个类型检查的,可以与rebar 以及非rebar 项目集成

参考使用

基于rebar的项目

 
{erl_opts, [debug_info]}.
 
{deps, [
  {eqwalizer_support,
    {git_subdir,
        "https://github.com/whatsapp/eqwalizer.git",
        {branch, "main"},
        "eqwalizer_support"}}
]}.
 
{shell, [
    {apps, [second]}
]}.
 
 
{project_plugins, [
  {eqwalizer_rebar3,
    {git_subdir,
        "https://github.com/whatsapp/eqwalizer.git",
        {branch, "main"},
        "eqwalizer_rebar3"}}
]}.
  • 使用命令
elp eqwalize-all

效果

添加一个类型check

 
-module(second_demo).
 
-export([demo/1]).
 
 
-spec demo(atom()) -> atom().
demo(name) ->
    name,
    ok.

调用

start(_StartType, _StartArgs) ->
    second_demo:demo("name"),
    second_sup:start_link().

效果

参考资料

https://github.com/WhatsApp/eqwalizer
https://rebar3.org/docs/configuration/plugins/#quickcheck
https://github.com/WhatsApp/eqwalizer/blob/main/FAQ.md

posted on 2023-12-26 16:31  荣锋亮  阅读(20)  评论(0编辑  收藏  举报

导航