fix(bpapi): Fix dialyzer warnings

This commit is contained in:
k32 2022-01-05 11:27:56 +01:00
parent 4f3f938d71
commit 9c675194f5
2 changed files with 19 additions and 21 deletions

View File

@ -72,21 +72,22 @@ check_compat(Dump1, Dump2) ->
check_api_immutability(#{release := Rel1, api := APIs1}, #{release := Rel2, api := APIs2})
when Rel2 >= Rel1 ->
%% TODO: Handle API deprecation
maps:map(fun(Key = {API, Version}, Val) ->
case maps:get(Key, APIs2, undefined) of
Val ->
ok;
undefined ->
setnok(),
?ERROR("API ~p v~p was removed in release ~p without being deprecated.",
[API, Version, Rel2]);
_Val ->
setnok(),
?ERROR("API ~p v~p was changed between ~p and ~p. Backplane API should be immutable.",
[API, Version, Rel1, Rel2])
end
end,
APIs1),
_ = maps:map(
fun(Key = {API, Version}, Val) ->
case maps:get(Key, APIs2, undefined) of
Val ->
ok;
undefined ->
setnok(),
?ERROR("API ~p v~p was removed in release ~p without being deprecated.",
[API, Version, Rel2]);
_Val ->
setnok(),
?ERROR("API ~p v~p was changed between ~p and ~p. Backplane API should be immutable.",
[API, Version, Rel1, Rel2])
end
end,
APIs1),
ok;
check_api_immutability(_, _) ->
ok.

View File

@ -31,7 +31,7 @@
, module :: atom()
, version :: non_neg_integer() | undefined
, targets = [] :: [{semantics(), emqx_bpapi:call(), emqx_bpapi:call()}]
, errors = [] :: [string()]
, errors = [] :: list()
, file
}).
@ -120,7 +120,7 @@ analyze_exprs(Line, Name, Arity, Head, Exprs, S) ->
invalid_fun(Line, Name, Arity, S)
end.
-spec extract_outer_args(erl_parse:abstract_form()) -> [atom()].
-spec extract_outer_args([erl_parse:abstract_form()]) -> [atom()].
extract_outer_args(Abs) ->
lists:map(fun({var, _, Var}) ->
Var;
@ -131,8 +131,7 @@ extract_outer_args(Abs) ->
end,
Abs).
-spec extract_target_call(Abs, [Abs]) -> {semantics(), emqx_bpapi:call()}
when Abs :: erl_parse:abstract_form().
-spec extract_target_call(_AST, [_AST]) -> {semantics(), emqx_bpapi:call()}.
extract_target_call(RPCBackend, OuterArgs) ->
{Semantics, {atom, _, M}, {atom, _, F}, A} = extract_mfa(RPCBackend, OuterArgs),
{Semantics, {M, F, list_to_args(A)}}.
@ -140,8 +139,6 @@ extract_target_call(RPCBackend, OuterArgs) ->
-define(BACKEND(MOD, FUN), {remote, _, {atom, _, MOD}, {atom, _, FUN}}).
-define(IS_RPC(MOD), (MOD =:= erpc orelse MOD =:= rpc)).
-spec extract_mfa(Abs, #s{}) -> {call | cast, Abs, Abs, Abs}
when Abs :: erl_parse:abstract_form().
%% gen_rpc:
extract_mfa(?BACKEND(gen_rpc, _), _) ->
%% gen_rpc has an extremely messy API, thankfully it's fully wrapped