Jelajahi Sumber

fix: elvis warning

Zhongwen Deng 4 tahun lalu
induk
melakukan
6ff2db6180

+ 6 - 3
apps/emqx/src/emqx_config_handler.erl

@@ -260,17 +260,20 @@ call_pre_config_update(#{?MOD := HandlerName}, OldRawConf, UpdateReq, ConfKeyPat
 call_pre_config_update(_Handlers, OldRawConf, UpdateReq, _ConfKeyPath) ->
     merge_to_old_config(UpdateReq, OldRawConf).
 
-call_post_config_update(#{?MOD := HandlerName}, OldConf, NewConf, AppEnvs, UpdateReq, Result, ConfKeyPath) ->
+call_post_config_update(#{?MOD := HandlerName}, OldConf, NewConf,
+    AppEnvs, UpdateReq, Result, ConfKeyPath) ->
     case erlang:function_exported(HandlerName, post_config_update, 5) of
         true ->
-            case HandlerName:post_config_update(ConfKeyPath, UpdateReq, NewConf, OldConf, AppEnvs) of
+            case HandlerName:post_config_update(ConfKeyPath, UpdateReq,
+                NewConf, OldConf, AppEnvs) of
                 ok -> {ok, Result};
                 {ok, Result1} -> {ok, Result#{HandlerName => Result1}};
                 {error, Reason} -> {error, {post_config_update, HandlerName, Reason}}
             end;
         false -> {ok, Result}
     end;
-call_post_config_update(_Handlers, _OldConf, _NewConf, _AppEnvs, _UpdateReq, Result, _ConfKeyPath) ->
+call_post_config_update(_Handlers, _OldConf, _NewConf, _AppEnvs,
+    _UpdateReq, Result, _ConfKeyPath) ->
     {ok, Result}.
 
 save_configs(ConfKeyPath, AppEnvs, CheckedConf, NewRawConf, OverrideConf, UpdateArgs, Opts) ->

+ 2 - 2
apps/emqx/src/emqx_map_lib.erl

@@ -61,8 +61,8 @@ deep_find([Key | KeyPath] = Path, Map) when is_map(Map) ->
         {ok, SubMap} -> deep_find(KeyPath, SubMap);
         error -> {not_found, Path, Map}
     end;
-deep_find(_KeyPath, Data) ->
-    {not_found, _KeyPath, Data}.
+deep_find(KeyPath, Data) ->
+    {not_found, KeyPath, Data}.
 
 -spec deep_put(config_key_path(), map(), term()) -> map().
 deep_put([], _Map, Data) ->

+ 7 - 3
apps/emqx/src/emqx_schema.erl

@@ -21,6 +21,7 @@
 -dialyzer(no_contracts).
 -dialyzer(no_unused).
 -dialyzer(no_fail_call).
+-elvis([{elvis_style, invalid_dynamic_call, disable}]).
 
 -include("emqx_authentication.hrl").
 -include_lib("typerefl/include/types.hrl").
@@ -382,7 +383,8 @@ after idling for 'Keepalive * backoff * 2'."""
     , {"max_inflight",
        sc(range(1, 65535),
           #{ default => 32,
-             desc => "Maximum size of the Inflight Window storing QoS1/2 messages delivered but un-acked."
+             desc => "Maximum size of the Inflight Window storing QoS1/2"
+                     " messages delivered but un-acked."
            })
       }
     , {"retry_interval",
@@ -400,7 +402,8 @@ after idling for 'Keepalive * backoff * 2'."""
     , {"await_rel_timeout",
        sc(duration(),
           #{ default => "300s",
-             desc => "The QoS2 messages (Client -> Broker) will be dropped if awaiting PUBREL timeout."
+             desc => "The QoS2 messages (Client -> Broker) will be dropped"
+                     " if awaiting PUBREL timeout."
            })
       }
     , {"session_expiry_interval",
@@ -1099,7 +1102,8 @@ fields("trace") ->
         default => text,
         desc => """
 Determine the format of the payload format in the trace file.<br>
-`text`: Text-based protocol or plain text protocol. It is recommended when payload is JSON encoded.<br>
+`text`: Text-based protocol or plain text protocol.
+ It is recommended when payload is JSON encoded.<br>
 `hex`: Binary hexadecimal encode. It is recommended when payload is a custom binary protocol.<br>
 `hidden`: payload is obfuscated as `******`
         """

+ 3 - 1
apps/emqx/test/emqx_authentication_SUITE.erl

@@ -35,7 +35,9 @@
 %% Hocon Schema
 %%------------------------------------------------------------------------------
 
-roots() -> [{config, #{type => hoconsc:union([hoconsc:ref(?MODULE, type1), hoconsc:ref(?MODULE, type2)])}}].
+roots() -> [{config, #{type => hoconsc:union([
+                                              hoconsc:ref(?MODULE, type1),
+                                              hoconsc:ref(?MODULE, type2)])}}].
 
 fields(type1) ->
     [ {mechanism,               {enum, ['password-based']}}

+ 17 - 7
apps/emqx_authz/src/emqx_authz_api_sources.erl

@@ -83,26 +83,33 @@ schema("/authorization/sources") ->
      , get =>
            #{ description => <<"List all authorization sources">>
             , responses =>
-                  #{ 200 => mk( array(hoconsc:union([ref(?API_SCHEMA_MODULE, Type) || Type <- authz_sources_types(detailed)]))
+                  #{ 200 => mk( array(hoconsc:union(
+                      [ref(?API_SCHEMA_MODULE, Type) || Type <- authz_sources_types(detailed)]))
                               , #{desc => <<"Authorization source">>})
                    }
             }
      , post =>
            #{ description => <<"Add a new source">>
-            , 'requestBody' => mk( hoconsc:union([ref(?API_SCHEMA_MODULE, Type) || Type <- authz_sources_types(detailed)])
+            , 'requestBody' => mk( hoconsc:union(
+                                   [ref(?API_SCHEMA_MODULE, Type)
+                                        || Type <- authz_sources_types(detailed)])
                                  , #{desc => <<"Source config">>})
             , responses =>
                   #{ 204 => <<"Authorization source created successfully">>
-                   , 400 => emqx_dashboard_swagger:error_codes([?BAD_REQUEST], <<"Bad Request">>)
+                   , 400 => emqx_dashboard_swagger:error_codes([?BAD_REQUEST],
+                                                               <<"Bad Request">>)
                    }
             }
      , put =>
            #{ description => <<"Update all sources">>
-            , 'requestBody' => mk( array(hoconsc:union([ref(?API_SCHEMA_MODULE, Type) || Type <- authz_sources_types(detailed)]))
+            , 'requestBody' => mk( array(hoconsc:union(
+                                  [ref(?API_SCHEMA_MODULE, Type)
+                                       || Type <- authz_sources_types(detailed)]))
                                  , #{desc => <<"Sources">>})
             , responses =>
                   #{ 204 => <<"Authorization source updated successfully">>
-                   , 400 => emqx_dashboard_swagger:error_codes([?BAD_REQUEST], <<"Bad Request">>)
+                   , 400 => emqx_dashboard_swagger:error_codes([?BAD_REQUEST],
+                              <<"Bad Request">>)
                    }
             }
      };
@@ -112,7 +119,9 @@ schema("/authorization/sources/:type") ->
            #{ description => <<"Get a authorization source">>
             , parameters => parameters_field()
             , responses =>
-                  #{ 200 => mk( hoconsc:union([ref(?API_SCHEMA_MODULE, Type) || Type <- authz_sources_types(detailed)])
+                  #{ 200 => mk( hoconsc:union(
+                               [ref(?API_SCHEMA_MODULE, Type)
+                                   || Type <- authz_sources_types(detailed)])
                               , #{desc => <<"Authorization source">>})
                    , 404 => emqx_dashboard_swagger:error_codes([?NOT_FOUND], <<"Not Found">>)
                    }
@@ -120,7 +129,8 @@ schema("/authorization/sources/:type") ->
      , put =>
            #{ description => <<"Update source">>
             , parameters => parameters_field()
-            , 'requestBody' => mk( hoconsc:union([ref(?API_SCHEMA_MODULE, Type) || Type <- authz_sources_types(detailed)]))
+            , 'requestBody' => mk( hoconsc:union([ref(?API_SCHEMA_MODULE, Type)
+                                   || Type <- authz_sources_types(detailed)]))
             , responses =>
                   #{ 204 => <<"Authorization source updated successfully">>
                    , 400 => emqx_dashboard_swagger:error_codes([?BAD_REQUEST], <<"Bad Request">>)

+ 14 - 7
apps/emqx_conf/src/emqx_conf_schema.erl

@@ -315,19 +315,22 @@ a crash dump"
        sc(emqx_schema:duration(),
           #{ mapping => "vm_args.-kernel net_ticktime"
            , default => "2m"
-           , desc => "This is the approximate time an EMQX node may be unresponsive until it is considered down and thereby disconnected."
+           , desc => "This is the approximate time an EMQX node may"
+                     " be unresponsive until it is considered down and thereby disconnected."
            })}
     , {"dist_listen_min",
        sc(range(1024, 65535),
           #{ mapping => "kernel.inet_dist_listen_min"
            , default => 6369
-           , desc => "Lower bound for the port range where EMQX broker listens for peer connections."
+           , desc => "Lower bound for the port range where"
+                     " EMQX broker listens for peer connections."
            })}
     , {"dist_listen_max",
        sc(range(1024, 65535),
           #{ mapping => "kernel.inet_dist_listen_max"
            , default => 6369
-           , desc => "Upper bound for the port range where EMQX broker listens for peer connections."
+           , desc => "Upper bound for the port range "
+                     "where EMQX broker listens for peer connections."
            })}
     , {"backtrace_depth",
        sc(integer(),
@@ -455,7 +458,8 @@ fields("rpc") ->
           #{ mapping => "gen_rpc.port_discovery"
            , default => stateless
            , desc => "<code>manual</code>: discover ports by <code>tcp_server_port</code>.<br/>"
-                     "<code>stateless</code>: discover ports in a stateless manner, using the following algorithm. "
+                     "<code>stateless</code>: discover ports in a stateless manner,"
+                     " using the following algorithm. "
                      "If node name is <code>emqxN@127.0.0.1</code>, where the N is an integer, "
                      "then the listening port will be 5370 + N."
            })}
@@ -464,7 +468,8 @@ fields("rpc") ->
           #{ mapping => "gen_rpc.tcp_server_port"
            , default => 5369
            , desc => "Listening port used by RPC local service.<br/> "
-                     "Note that this config only takes effect when rpc.port_discovery is set to manual."
+                     "Note that this config only takes effect "
+                     "when rpc.port_discovery is set to manual."
            })}
     , {"ssl_server_port",
        sc(integer(),
@@ -497,7 +502,8 @@ fields("rpc") ->
        sc(file(),
           #{ mapping => "gen_rpc.keyfile"
            , desc => "Path to the private key file for the <code>rpc.certfile</code>.<br/>"
-                     "Note: contents of this file are secret, so it's necessary to set permissions to 600."
+                     "Note: contents of this file are secret, so it's necessary to "
+                     "set permissions to 600."
            })}
     , {"cacertfile",
        sc(file(),
@@ -528,7 +534,8 @@ fields("rpc") ->
        sc(emqx_schema:duration_s(),
           #{ mapping => "gen_rpc.socket_keepalive_idle"
            , default => "7200s"
-           , desc => "How long the connections between the brokers should remain open after the last message is sent."
+           , desc => "How long the connections between the brokers should remain open "
+                     "after the last message is sent."
            })}
     , {"socket_keepalive_interval",
        sc(emqx_schema:duration_s(),

+ 4 - 2
apps/emqx_connector/test/emqx_connector_api_SUITE.erl

@@ -91,12 +91,14 @@ init_per_suite(Config) ->
     ok = emqx_common_test_helpers:start_apps([emqx_rule_engine, emqx_connector,
         emqx_bridge, emqx_dashboard], fun set_special_configs/1),
     ok = emqx_common_test_helpers:load_config(emqx_connector_schema, <<"connectors: {}">>),
-    ok = emqx_common_test_helpers:load_config(emqx_rule_engine_schema, <<"rule_engine {rules {}}">>),
+    ok = emqx_common_test_helpers:load_config(emqx_rule_engine_schema,
+                                              <<"rule_engine {rules {}}">>),
     ok = emqx_common_test_helpers:load_config(emqx_bridge_schema, ?BRIDGE_CONF_DEFAULT),
     Config.
 
 end_per_suite(_Config) ->
-    emqx_common_test_helpers:stop_apps([emqx_rule_engine, emqx_connector, emqx_bridge, emqx_dashboard]),
+    emqx_common_test_helpers:stop_apps([emqx_rule_engine,
+        emqx_connector, emqx_bridge, emqx_dashboard]),
     ok.
 
 set_special_configs(emqx_dashboard) ->