style: fix some elvis style check
This commit is contained in:
parent
6edd862dd5
commit
f84d1aa75e
|
|
@ -20,6 +20,7 @@
|
|||
-include("logger.hrl").
|
||||
-include("types.hrl").
|
||||
|
||||
-elvis([{elvis_style, god_modules, disable}]).
|
||||
|
||||
%% Start/Stop the application
|
||||
-export([ start/0
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
-module(emqx_misc).
|
||||
|
||||
-compile(inline).
|
||||
-elvis([{elvis_style, god_modules, disable}]).
|
||||
|
||||
-include("types.hrl").
|
||||
-include("logger.hrl").
|
||||
|
|
@ -92,9 +93,9 @@ maybe_apply(Fun, Arg) when is_function(Fun) ->
|
|||
-spec(compose(list(F)) -> G
|
||||
when F :: fun((any()) -> any()),
|
||||
G :: fun((any()) -> any())).
|
||||
compose([F|More]) -> compose(F, More).
|
||||
compose([F | More]) -> compose(F, More).
|
||||
|
||||
-spec(compose(F, G|[Gs]) -> C
|
||||
-spec(compose(F, G | [Gs]) -> C
|
||||
when F :: fun((X1) -> X2),
|
||||
G :: fun((X2) -> X3),
|
||||
Gs :: [fun((Xn) -> Xn1)],
|
||||
|
|
@ -102,19 +103,19 @@ compose([F|More]) -> compose(F, More).
|
|||
X3 :: any(), Xn :: any(), Xn1 :: any(), Xm :: any()).
|
||||
compose(F, G) when is_function(G) -> fun(X) -> G(F(X)) end;
|
||||
compose(F, [G]) -> compose(F, G);
|
||||
compose(F, [G|More]) -> compose(compose(F, G), More).
|
||||
compose(F, [G | More]) -> compose(compose(F, G), More).
|
||||
|
||||
%% @doc RunFold
|
||||
run_fold([], Acc, _State) ->
|
||||
Acc;
|
||||
run_fold([Fun|More], Acc, State) ->
|
||||
run_fold([Fun | More], Acc, State) ->
|
||||
run_fold(More, Fun(Acc, State), State).
|
||||
|
||||
%% @doc Pipeline
|
||||
pipeline([], Input, State) ->
|
||||
{ok, Input, State};
|
||||
|
||||
pipeline([Fun|More], Input, State) ->
|
||||
pipeline([Fun | More], Input, State) ->
|
||||
case apply_fun(Fun, Input, State) of
|
||||
ok -> pipeline(More, Input, State);
|
||||
{ok, NState} ->
|
||||
|
|
@ -163,7 +164,7 @@ drain_deliver(0, Acc) ->
|
|||
drain_deliver(N, Acc) ->
|
||||
receive
|
||||
Deliver = {deliver, _Topic, _Msg} ->
|
||||
drain_deliver(N-1, [Deliver|Acc])
|
||||
drain_deliver(N-1, [Deliver | Acc])
|
||||
after 0 ->
|
||||
lists:reverse(Acc)
|
||||
end.
|
||||
|
|
@ -178,7 +179,7 @@ drain_down(0, Acc) ->
|
|||
drain_down(Cnt, Acc) ->
|
||||
receive
|
||||
{'DOWN', _MRef, process, Pid, _Reason} ->
|
||||
drain_down(Cnt-1, [Pid|Acc])
|
||||
drain_down(Cnt-1, [Pid | Acc])
|
||||
after 0 ->
|
||||
lists:reverse(Acc)
|
||||
end.
|
||||
|
|
@ -205,7 +206,7 @@ check_oom(Pid, #{max_message_queue_len := MaxQLen,
|
|||
end.
|
||||
|
||||
do_check_oom([]) -> ok;
|
||||
do_check_oom([{Val, Max, Reason}|Rest]) ->
|
||||
do_check_oom([{Val, Max, Reason} | Rest]) ->
|
||||
case is_integer(Max) andalso (0 < Max) andalso (Max < Val) of
|
||||
true -> {shutdown, Reason};
|
||||
false -> do_check_oom(Rest)
|
||||
|
|
@ -248,8 +249,8 @@ proc_stats(Pid) ->
|
|||
reductions,
|
||||
memory]) of
|
||||
undefined -> [];
|
||||
[{message_queue_len, Len}|ProcStats] ->
|
||||
[{mailbox_len, Len}|ProcStats]
|
||||
[{message_queue_len, Len} | ProcStats] ->
|
||||
[{mailbox_len, Len} | ProcStats]
|
||||
end.
|
||||
|
||||
rand_seed() ->
|
||||
|
|
@ -269,9 +270,9 @@ index_of(E, L) ->
|
|||
|
||||
index_of(_E, _I, []) ->
|
||||
error(badarg);
|
||||
index_of(E, I, [E|_]) ->
|
||||
index_of(E, I, [E | _]) ->
|
||||
I;
|
||||
index_of(E, I, [_|L]) ->
|
||||
index_of(E, I, [_ | L]) ->
|
||||
index_of(E, I+1, L).
|
||||
|
||||
-spec(bin2hexstr_A_F(binary()) -> binary()).
|
||||
|
|
|
|||
Loading…
Reference in New Issue