Explorar el Código

style: fix some elvis style check

Zaiming Shi hace 4 años
padre
commit
f84d1aa75e
Se han modificado 2 ficheros con 14 adiciones y 12 borrados
  1. 1 0
      apps/emqx/src/emqx.erl
  2. 13 12
      apps/emqx/src/emqx_misc.erl

+ 1 - 0
apps/emqx/src/emqx.erl

@@ -20,6 +20,7 @@
 -include("logger.hrl").
 -include("logger.hrl").
 -include("types.hrl").
 -include("types.hrl").
 
 
+-elvis([{elvis_style, god_modules, disable}]).
 
 
 %% Start/Stop the application
 %% Start/Stop the application
 -export([ start/0
 -export([ start/0

+ 13 - 12
apps/emqx/src/emqx_misc.erl

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