From b7a9f1e087fff14bd67f5df0761d5f0e2c74ef69 Mon Sep 17 00:00:00 2001 From: EMQ-YangM Date: Fri, 11 Mar 2022 14:54:09 +0800 Subject: [PATCH] fix(emqx_map_lib): fix static checks errors --- apps/emqx/src/emqx_map_lib.erl | 11 ++--------- apps/emqx_authn/src/emqx_authn_api.erl | 4 +--- apps/emqx_authn/src/proto/emqx_authn_proto_v1.erl | 5 +---- apps/emqx_authn/test/emqx_authn_api_SUITE.erl | 2 +- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/apps/emqx/src/emqx_map_lib.erl b/apps/emqx/src/emqx_map_lib.erl index 11044ef74..c22a13e33 100644 --- a/apps/emqx/src/emqx_map_lib.erl +++ b/apps/emqx/src/emqx_map_lib.erl @@ -174,12 +174,6 @@ covert_keys_to_atom(BinKeyMap, Conv) -> %% copy from maps.erl OTP24.0 -compile({inline, [error_with_info/2]}). --spec merge_with(Combiner, Map1, Map2) -> Map3 when - Map1 :: #{Key1 => Value1}, - Map2 :: #{Key2 => Value2}, - Combiner :: fun((Key1, Value1, Value2) -> CombineResult), - Map3 :: #{Key1 => CombineResult, Key1 => Value1, Key2 => Value2}. - merge_with(Combiner, Map1, Map2) when is_map(Map1), is_map(Map2), is_function(Combiner, 3) -> @@ -217,11 +211,10 @@ error_type_merge_intersect(M1, M2, Combiner) when is_function(Combiner, 3) -> error_type_merge_intersect(_M1, _M2, _Combiner) -> badarg. -error_with_info(Reason, Args) -> - erlang:error(Reason, Args, [{error_info, #{module => erl_stdlib_errors}}]). +error_with_info(_, _) -> + {error_info, #{module => erl_stdlib_errors}}. error_type_two_maps(M1, M2) when is_map(M1) -> {badmap, M2}; error_type_two_maps(M1, _M2) -> {badmap, M1}. - diff --git a/apps/emqx_authn/src/emqx_authn_api.erl b/apps/emqx_authn/src/emqx_authn_api.erl index 37d41e344..1619d9239 100644 --- a/apps/emqx_authn/src/emqx_authn_api.erl +++ b/apps/emqx_authn/src/emqx_authn_api.erl @@ -827,7 +827,7 @@ aggregate_metrics([HeadMetrics | AllMetrics]) -> end end, Fun = fun (ElemMap, AccMap) -> - emqx_map_lib:merge_with(CombinerFun(CombinerFun), ElemMap, AccMap) end, + emqx_map_lib:merge_with(CombinerFun, ElemMap, AccMap) end, lists:foldl(Fun, HeadMetrics, AllMetrics). make_result_map(ResList) -> @@ -863,8 +863,6 @@ restructure_map(#{counters := #{failed := Failed, matched := Match, success := S restructure_map(Error) -> Error. -error_msg(Code, Msg) when is_binary(Msg) -> - #{code => Code, message => Msg}; error_msg(Code, Msg) -> #{code => Code, message => bin(io_lib:format("~p", [Msg]))}. diff --git a/apps/emqx_authn/src/proto/emqx_authn_proto_v1.erl b/apps/emqx_authn/src/proto/emqx_authn_proto_v1.erl index df5d19e94..1d93ded8e 100644 --- a/apps/emqx_authn/src/proto/emqx_authn_proto_v1.erl +++ b/apps/emqx_authn/src/proto/emqx_authn_proto_v1.erl @@ -29,10 +29,7 @@ introduced_in() -> "5.0.0". --type key() :: atom() | binary() | [byte()]. - --spec lookup_from_all_nodes([node()], key(), key()) -> +-spec lookup_from_all_nodes([node()], atom(), binary()) -> emqx_rpc:erpc_multicall(). lookup_from_all_nodes(Nodes, ChainName, AuthenticatorID) -> erpc:multicall(Nodes, emqx_authn_api, lookup_from_local_node, [ChainName, AuthenticatorID], ?TIMEOUT). - diff --git a/apps/emqx_authn/test/emqx_authn_api_SUITE.erl b/apps/emqx_authn/test/emqx_authn_api_SUITE.erl index 93dd5d084..cc6476f0b 100644 --- a/apps/emqx_authn/test/emqx_authn_api_SUITE.erl +++ b/apps/emqx_authn/test/emqx_authn_api_SUITE.erl @@ -166,7 +166,7 @@ test_authenticator(PathPrefix) -> ValidConfig0), {ok, 200, Res} = request( get, - uri(PathPrefix ++ [?CONF_NS, "password-based:http"])), + uri(PathPrefix ++ [?CONF_NS, "password_based:http"])), {ok, RList} = emqx_json:safe_decode(Res), Snd = fun ({_, Val}) -> Val end, LookupVal = fun LookupV(List, RestJson) ->