fix(emqx_authn_api): fix elvis error

This commit is contained in:
EMQ-YangM 2022-03-11 12:46:12 +08:00
parent 48b167bf46
commit 7165fbc5ca
3 changed files with 9 additions and 9 deletions

View File

@ -186,13 +186,13 @@ merge_with(Combiner, Map1, Map2) when is_map(Map1),
case map_size(Map1) > map_size(Map2) of case map_size(Map1) > map_size(Map2) of
true -> true ->
Iterator = maps:iterator(Map2), Iterator = maps:iterator(Map2),
merge_with_1(maps:next(Iterator), merge_with_t(maps:next(Iterator),
Map1, Map1,
Map2, Map2,
Combiner); Combiner);
false -> false ->
Iterator = maps:iterator(Map1), Iterator = maps:iterator(Map1),
merge_with_1(maps:next(Iterator), merge_with_t(maps:next(Iterator),
Map2, Map2,
Map1, Map1,
fun(K, V1, V2) -> Combiner(K, V2, V1) end) fun(K, V1, V2) -> Combiner(K, V2, V1) end)
@ -201,15 +201,15 @@ merge_with(Combiner, Map1, Map2) ->
error_with_info(error_type_merge_intersect(Map1, Map2, Combiner), error_with_info(error_type_merge_intersect(Map1, Map2, Combiner),
[Combiner, Map1, Map2]). [Combiner, Map1, Map2]).
merge_with_1({K, V2, Iterator}, Map1, Map2, Combiner) -> merge_with_t({K, V2, Iterator}, Map1, Map2, Combiner) ->
case Map1 of case Map1 of
#{ K := V1 } -> #{ K := V1 } ->
NewMap1 = Map1#{ K := Combiner(K, V1, V2) }, NewMap1 = Map1#{ K := Combiner(K, V1, V2) },
merge_with_1(maps:next(Iterator), NewMap1, Map2, Combiner); merge_with_t(maps:next(Iterator), NewMap1, Map2, Combiner);
#{ } -> #{ } ->
merge_with_1(maps:next(Iterator), maps:put(K, V2, Map1), Map2, Combiner) merge_with_t(maps:next(Iterator), maps:put(K, V2, Map1), Map2, Combiner)
end; end;
merge_with_1(none, Result, _, _) -> merge_with_t(none, Result, _, _) ->
Result. Result.
error_type_merge_intersect(M1, M2, Combiner) when is_function(Combiner, 3) -> error_type_merge_intersect(M1, M2, Combiner) when is_function(Combiner, 3) ->

View File

@ -756,9 +756,9 @@ list_authenticator(ChainName, ConfKeyPath, AuthenticatorID) ->
AuthenticatorsConfig = get_raw_config_with_defaults(ConfKeyPath), AuthenticatorsConfig = get_raw_config_with_defaults(ConfKeyPath),
case find_config(AuthenticatorID, AuthenticatorsConfig) of case find_config(AuthenticatorID, AuthenticatorsConfig) of
{ok, AuthenticatorConfig} -> {ok, AuthenticatorConfig} ->
Status_And_Metrics = lookup_from_all_nodes(ChainName, AuthenticatorID), StatusAndMetrics = lookup_from_all_nodes(ChainName, AuthenticatorID),
Fun = fun ({Key, Val}, Map) -> maps:put(Key, Val, Map) end, Fun = fun ({Key, Val}, Map) -> maps:put(Key, Val, Map) end,
AppendList = [{id, AuthenticatorID}, {status_and_metrics, Status_And_Metrics}], AppendList = [{id, AuthenticatorID}, {status_and_metrics, StatusAndMetrics}],
{200, lists:foldl(Fun, convert_certs(AuthenticatorConfig), AppendList)}; {200, lists:foldl(Fun, convert_certs(AuthenticatorConfig), AppendList)};
{error, Reason} -> {error, Reason} ->
serialize_error(Reason) serialize_error(Reason)

View File

@ -178,7 +178,7 @@ test_authenticator(PathPrefix) ->
end end
end end
end, end,
LookFun = fun (List) -> (LookupVal(LookupVal)) (List, RList) end, LookFun = fun (List) -> (LookupVal(LookupVal))(List, RList) end,
MetricsList = [{<<"failed">>, 0}, MetricsList = [{<<"failed">>, 0},
{<<"matched">>, 0}, {<<"matched">>, 0},
{<<"rate">>, 0.0}, {<<"rate">>, 0.0},