chore(gw): fix elvis warnings

This commit is contained in:
JianBo He 2021-11-22 10:14:13 +08:00
parent f033fad7b3
commit 4f752fb5ab
6 changed files with 33 additions and 23 deletions

View File

@ -74,6 +74,8 @@
, serialize_error/1
]).
-elvis([{elvis_style, god_modules, disable}]).
api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -173,7 +173,7 @@ schema("/gateway/:name/authentication") ->
put =>
#{ description => <<"Update authentication for the gateway">>
, parameters => params_gateway_name_in_path()
, requestBody => schema_authn()
, 'requestBody' => schema_authn()
, responses =>
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
@ -185,7 +185,7 @@ schema("/gateway/:name/authentication") ->
post =>
#{ description => <<"Add authentication for the gateway">>
, parameters => params_gateway_name_in_path()
, requestBody => schema_authn()
, 'requestBody' => schema_authn()
, responses =>
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
@ -289,7 +289,7 @@ schema("/gateway/:name/authentication/import_users") ->
, post =>
#{ description => <<"Import users into the gateway authentication">>
, parameters => params_gateway_name_in_path()
, requestBody => emqx_dashboard_swagger:schema_with_examples(
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
ref(emqx_authn_api, request_import_users),
emqx_authn_api:request_import_users_examples()
)

View File

@ -179,7 +179,7 @@ schema("/gateway/:name/listeners") ->
post =>
#{ description => <<"Create the gateway listener">>
, parameters => params_gateway_name_in_path()
, requestBody => emqx_dashboard_swagger:schema_with_examples(
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
ref(listener),
examples_listener())
, responses =>
@ -223,7 +223,7 @@ schema("/gateway/:name/listeners/:id") ->
#{ description => <<"Update the gateway listener">>
, parameters => params_gateway_name_in_path()
++ params_listener_id_in_path()
, requestBody => emqx_dashboard_swagger:schema_with_examples(
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
ref(listener),
examples_listener())
, responses =>
@ -254,7 +254,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
#{ description => <<"Add authentication for the listener">>
, parameters => params_gateway_name_in_path()
++ params_listener_id_in_path()
, requestBody => schema_authn()
, 'requestBody' => schema_authn()
, responses =>
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
@ -267,7 +267,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
#{ description => <<"Update authentication for the listener">>
, parameters => params_gateway_name_in_path()
++ params_listener_id_in_path()
, requestBody => schema_authn()
, 'requestBody' => schema_authn()
, responses =>
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)

View File

@ -70,6 +70,10 @@
, listeners => []
}.
-elvis([{elvis_style, god_modules, disable}]).
-elvis([{elvis_style, no_nested_try_catch, disable}]).
-define(DEFAULT_CALL_TIMEOUT, 15000).
%%--------------------------------------------------------------------

View File

@ -52,6 +52,8 @@
stopped_at :: integer() | undefined
}).
-elvis([{elvis_style, invalid_dynamic_call, disable}]).
%%--------------------------------------------------------------------
%% APIs
%%--------------------------------------------------------------------
@ -312,13 +314,13 @@ do_update_one_by_one(NCfg, State = #state{
OAuths = authns(GwName, OCfg),
NAuths = authns(GwName, NCfg),
if
Status == stopped, NEnable == true ->
case {Status, NEnable} of
{stopped, true} ->
NState = State#state{config = NCfg},
cb_gateway_load(NState);
Status == stopped, NEnable == false ->
{stopped, false} ->
{ok, State#state{config = NCfg}};
Status == running, NEnable == true ->
{running, true} ->
NState = case NAuths == OAuths of
true -> State;
false ->
@ -329,12 +331,12 @@ do_update_one_by_one(NCfg, State = #state{
end,
%% XXX: minimum impact update ???
cb_gateway_update(NCfg, NState);
Status == running, NEnable == false ->
{running, false} ->
case cb_gateway_unload(State) of
{ok, NState} -> {ok, NState#state{config = NCfg}};
{error, Reason} -> {error, Reason}
end;
true ->
_ ->
throw(nomatch)
end.

View File

@ -66,6 +66,8 @@
-define(DEFAULT_OOM_POLICY, #{max_heap_size => 4194304,
message_queue_len => 32000}).
-elvis([{elvis_style, god_modules, disable}]).
-spec childspec(supervisor:worker(), Mod :: atom())
-> supervisor:child_spec().
childspec(Type, Mod) ->