fix(dialyzer): batch 3

This commit is contained in:
Zaiming (Stone) Shi 2023-12-08 20:55:07 +01:00
parent 107efda78f
commit 50f4aba5cd
22 changed files with 49 additions and 34 deletions

View File

@ -979,7 +979,7 @@ handle_cast(Req, State) ->
%% rate limit %% rate limit
-type limiter_type() :: emqx_limiter_container:limiter_type(). -type limiter_type() :: emqx_limiter_container:limiter_type().
-type limiter() :: emqx_limiter_container:limiter(). -type limiter() :: emqx_limiter_container:container().
-type check_succ_handler() :: -type check_succ_handler() ::
fun((any(), list(any()), state()) -> _). fun((any(), list(any()), state()) -> _).

View File

@ -138,7 +138,7 @@ compact_errors(SchemaModule, Error, Stacktrace) ->
}}. }}.
%% @doc This is only used in static check scripts in the CI. %% @doc This is only used in static check scripts in the CI.
-spec load_and_check(module(), filename:filename_all()) -> {ok, term()} | {error, any()}. -spec load_and_check(module(), file:name_all()) -> {ok, term()} | {error, any()}.
load_and_check(SchemaModule, File) -> load_and_check(SchemaModule, File) ->
try try
do_load_and_check(SchemaModule, File) do_load_and_check(SchemaModule, File)

View File

@ -125,12 +125,12 @@ when
-callback 'client.subscribe'(emqx_types:clientinfo(), emqx_types:properties(), TopicFilters) -> -callback 'client.subscribe'(emqx_types:clientinfo(), emqx_types:properties(), TopicFilters) ->
fold_callback_result(TopicFilters) fold_callback_result(TopicFilters)
when when
TopicFilters :: list({emqx_topic:topic(), map()}). TopicFilters :: list({emqx_types:topic(), map()}).
-callback 'client.unsubscribe'(emqx_types:clientinfo(), emqx_types:properties(), TopicFilters) -> -callback 'client.unsubscribe'(emqx_types:clientinfo(), emqx_types:properties(), TopicFilters) ->
fold_callback_result(TopicFilters) fold_callback_result(TopicFilters)
when when
TopicFilters :: list({emqx_topic:topic(), map()}). TopicFilters :: list({emqx_types:topic(), map()}).
-callback 'client.timeout'(_TimerReference :: reference(), _Msg :: term(), Replies) -> -callback 'client.timeout'(_TimerReference :: reference(), _Msg :: term(), Replies) ->
fold_callback_result(Replies) fold_callback_result(Replies)

View File

@ -32,7 +32,7 @@
make_future/1, make_future/1,
available/1 available/1
]). ]).
-export_type([local_limiter/0, limiter/0]). -export_type([local_limiter/0, limiter/0, retry_context/1]).
%% a token bucket limiter which may or not contains a reference to another limiter, %% a token bucket limiter which may or not contains a reference to another limiter,
%% and can be used in a client alone %% and can be used in a client alone

View File

@ -51,7 +51,7 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% API %% API
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-spec new(counters:countres_ref(), index(), rate()) -> bucket_ref(). -spec new(counters:counters_ref(), index(), rate()) -> bucket_ref().
new(Counter, Index, Rate) -> new(Counter, Index, Rate) ->
#{ #{
counter => Counter, counter => Counter,

View File

@ -32,7 +32,7 @@
retry_list/2 retry_list/2
]). ]).
-export_type([container/0, check_result/0]). -export_type([limiter/0, container/0, check_result/0, limiter_type/0]).
-type container() :: -type container() ::
infinity infinity
@ -51,7 +51,7 @@
-type limiter_id() :: emqx_limiter_schema:limiter_id(). -type limiter_id() :: emqx_limiter_schema:limiter_id().
-type limiter_type() :: emqx_limiter_schema:limiter_type(). -type limiter_type() :: emqx_limiter_schema:limiter_type().
-type limiter() :: emqx_htb_limiter:limiter(). -type limiter() :: emqx_htb_limiter:limiter().
-type retry_context() :: emqx_htb_limiter:retry_context(). -type retry_context() :: emqx_htb_limiter:retry_context(limiter()).
-type millisecond() :: non_neg_integer(). -type millisecond() :: non_neg_integer().
-type check_result() :: -type check_result() ::
{ok, container()} {ok, container()}

View File

@ -63,6 +63,8 @@
-export([certs_dir/2]). -export([certs_dir/2]).
-endif. -endif.
-export_type([listener_id/0]).
-type listener_id() :: atom() | binary(). -type listener_id() :: atom() | binary().
-define(ROOT_KEY, listeners). -define(ROOT_KEY, listeners).
-define(CONF_KEY_PATH, [?ROOT_KEY, '?', '?']). -define(CONF_KEY_PATH, [?ROOT_KEY, '?', '?']).

View File

@ -72,7 +72,7 @@
%% BACKW: v4.3.0 %% BACKW: v4.3.0
-export([upgrade_retained_delayed_counter_type/0]). -export([upgrade_retained_delayed_counter_type/0]).
-export_type([metric_idx/0]). -export_type([metric_idx/0, metric_name/0]).
-compile({inline, [inc/1, inc/2, dec/1, dec/2]}). -compile({inline, [inc/1, inc/2, dec/1, dec/2]}).
-compile({inline, [inc_recv/1, inc_sent/1]}). -compile({inline, [inc_recv/1, inc_sent/1]}).
@ -438,7 +438,7 @@ update_counter(Name, Value) ->
%% Inc received/sent metrics %% Inc received/sent metrics
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-spec inc_msg(emqx_types:massage()) -> ok. -spec inc_msg(emqx_types:message()) -> ok.
inc_msg(Msg) -> inc_msg(Msg) ->
case Msg#message.qos of case Msg#message.qos of
0 -> inc('messages.qos0.received'); 0 -> inc('messages.qos0.received');

View File

@ -85,6 +85,12 @@
]). ]).
-endif. -endif.
-export_type([
id/0,
subscription_id/0,
session/0
]).
%% Currently, this is the clientid. We avoid `emqx_types:clientid()' because that can be %% Currently, this is the clientid. We avoid `emqx_types:clientid()' because that can be
%% an atom, in theory (?). %% an atom, in theory (?).
-type id() :: binary(). -type id() :: binary().
@ -145,8 +151,6 @@
(NOW_MS >= LAST_ALIVE_AT + EI)) (NOW_MS >= LAST_ALIVE_AT + EI))
). ).
-export_type([id/0]).
%% %%
-spec create(clientinfo(), conninfo(), emqx_session:conf()) -> -spec create(clientinfo(), conninfo(), emqx_session:conf()) ->
@ -243,7 +247,7 @@ stats(Session) ->
info(?STATS_KEYS, Session). info(?STATS_KEYS, Session).
%% Debug/troubleshooting %% Debug/troubleshooting
-spec print_session(emqx_types:client_id()) -> map() | undefined. -spec print_session(emqx_types:clientid()) -> map() | undefined.
print_session(ClientId) -> print_session(ClientId) ->
catch ro_transaction( catch ro_transaction(
fun() -> fun() ->

View File

@ -24,7 +24,7 @@
dest :: emqx_persistent_session_ds:id() dest :: emqx_persistent_session_ds:id()
}). }).
-record(ps_routeidx, { -record(ps_routeidx, {
entry :: emqx_topic_index:key(emqx_persistent_session_ds_router:dest()), entry :: '$1' | emqx_topic_index:key(emqx_persistent_session_ds_router:dest()),
unused = [] :: nil() unused = [] :: nil()
}). }).

View File

@ -91,7 +91,7 @@
-type dest() :: node() | {group(), node()}. -type dest() :: node() | {group(), node()}.
-record(routeidx, { -record(routeidx, {
entry :: emqx_topic_index:key(dest()), entry :: '$1' | emqx_topic_index:key(dest()),
unused = [] :: nil() unused = [] :: nil()
}). }).

View File

@ -111,6 +111,7 @@
t/0, t/0,
conf/0, conf/0,
conninfo/0, conninfo/0,
clientinfo/0,
reply/0, reply/0,
replies/0, replies/0,
common_timer_name/0, common_timer_name/0,
@ -499,7 +500,7 @@ cancel_timer(Name, Timers0) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-spec disconnect(clientinfo(), eqmx_types:conninfo(), t()) -> -spec disconnect(clientinfo(), conninfo(), t()) ->
{idle | shutdown, t()}. {idle | shutdown, t()}.
disconnect(_ClientInfo, ConnInfo, Session) -> disconnect(_ClientInfo, ConnInfo, Session) ->
?IMPL(Session):disconnect(Session, ConnInfo). ?IMPL(Session):disconnect(Session, ConnInfo).

View File

@ -34,7 +34,7 @@
%% %%
-spec handle_event(emqx_session:client_info(), event()) -> -spec handle_event(emqx_session:clientinfo(), event()) ->
ok. ok.
handle_event(ClientInfo, {expired, Msg}) -> handle_event(ClientInfo, {expired, Msg}) ->
ok = emqx_hooks:run('delivery.dropped', [ClientInfo, Msg, expired]), ok = emqx_hooks:run('delivery.dropped', [ClientInfo, Msg, expired]),

View File

@ -30,8 +30,8 @@
-export([init/1]). -export([init/1]).
-type startchild_ret() :: -type startchild_ret() ::
{ok, supervisor:child()} {ok, pid()}
| {ok, supervisor:child(), term()} | {ok, pid(), term()}
| {error, term()}. | {error, term()}.
-define(SUP, ?MODULE). -define(SUP, ?MODULE).
@ -52,7 +52,7 @@ start_child(ChildSpec) when is_map(ChildSpec) ->
start_child(Mod, Type) -> start_child(Mod, Type) ->
start_child(child_spec(Mod, Type)). start_child(child_spec(Mod, Type)).
-spec stop_child(supervisor:child_id()) -> ok | {error, term()}. -spec stop_child(atom()) -> ok | {error, term()}.
stop_child(ChildId) -> stop_child(ChildId) ->
case supervisor:terminate_child(?SUP, ChildId) of case supervisor:terminate_child(?SUP, ChildId) of
ok -> supervisor:delete_child(?SUP, ChildId); ok -> supervisor:delete_child(?SUP, ChildId);

View File

@ -44,6 +44,9 @@
to_client_opts/2 to_client_opts/2
]). ]).
%% ssl:tls_version/0 is not exported.
-type tls_version() :: tlsv1 | 'tlsv1.1' | 'tlsv1.2' | 'tlsv1.3'.
-include("logger.hrl"). -include("logger.hrl").
-define(IS_TRUE(Val), ((Val =:= true) orelse (Val =:= <<"true">>))). -define(IS_TRUE(Val), ((Val =:= true) orelse (Val =:= <<"true">>))).
@ -123,8 +126,8 @@
%% @doc Validate a given list of desired tls versions. %% @doc Validate a given list of desired tls versions.
%% raise an error exception if non of them are available. %% raise an error exception if non of them are available.
%% The input list can be a string/binary of comma separated versions. %% The input list can be a string/binary of comma separated versions.
-spec integral_versions(tls | dtls, undefined | string() | binary() | [ssl:tls_version()]) -> -spec integral_versions(tls | dtls, undefined | string() | binary() | [tls_version()]) ->
[ssl:tls_version()]. [tls_version()].
integral_versions(Type, undefined) -> integral_versions(Type, undefined) ->
available_versions(Type); available_versions(Type);
integral_versions(Type, []) -> integral_versions(Type, []) ->
@ -164,7 +167,7 @@ all_ciphers() ->
all_ciphers(available_versions(all)). all_ciphers(available_versions(all)).
%% @hidden Return a list of (openssl string format) cipher suites. %% @hidden Return a list of (openssl string format) cipher suites.
-spec all_ciphers([ssl:tls_version()]) -> [string()]. -spec all_ciphers([tls_version()]) -> [string()].
all_ciphers(['tlsv1.3']) -> all_ciphers(['tlsv1.3']) ->
%% When it's only tlsv1.3 wanted, use 'exclusive' here %% When it's only tlsv1.3 wanted, use 'exclusive' here
%% because 'all' returns legacy cipher suites too, %% because 'all' returns legacy cipher suites too,
@ -212,7 +215,7 @@ do_selected_ciphers(_) ->
?SELECTED_CIPHERS. ?SELECTED_CIPHERS.
%% @doc Ensure version & cipher-suites integrity. %% @doc Ensure version & cipher-suites integrity.
-spec integral_ciphers([ssl:tls_version()], binary() | string() | [string()]) -> [string()]. -spec integral_ciphers([tls_version()], binary() | string() | [string()]) -> [string()].
integral_ciphers(Versions, Ciphers) when Ciphers =:= [] orelse Ciphers =:= undefined -> integral_ciphers(Versions, Ciphers) when Ciphers =:= [] orelse Ciphers =:= undefined ->
%% not configured %% not configured
integral_ciphers(Versions, selected_ciphers(Versions)); integral_ciphers(Versions, selected_ciphers(Versions));

View File

@ -20,6 +20,7 @@
%% SSL PSK Callbacks %% SSL PSK Callbacks
-export([lookup/3]). -export([lookup/3]).
-export_type([psk_identity/0]).
-type psk_identity() :: string(). -type psk_identity() :: string().
-type psk_user_state() :: term(). -type psk_user_state() :: term().

View File

@ -30,6 +30,8 @@
-export([get_topic/1]). -export([get_topic/1]).
-export([get_record/2]). -export([get_record/2]).
-export_type([key/1]).
-type key(ID) :: emqx_trie_search:key(ID). -type key(ID) :: emqx_trie_search:key(ID).
-type match(ID) :: key(ID). -type match(ID) :: key(ID).
-type words() :: emqx_trie_search:words(). -type words() :: emqx_trie_search:words().

View File

@ -19,11 +19,14 @@
-export([format/2]). -export([format/2]).
-export([format_meta_map/1]). -export([format_meta_map/1]).
%% logger_formatter:config/0 is not exported.
-type config() :: map().
%%%----------------------------------------------------------------- %%%-----------------------------------------------------------------
%%% API %%% API
-spec format(LogEvent, Config) -> unicode:chardata() when -spec format(LogEvent, Config) -> unicode:chardata() when
LogEvent :: logger:log_event(), LogEvent :: logger:log_event(),
Config :: logger:config(). Config :: config().
format( format(
#{level := debug, meta := Meta = #{trace_tag := Tag}, msg := Msg}, #{level := debug, meta := Meta = #{trace_tag := Tag}, msg := Msg},
#{payload_encode := PEncode} #{payload_encode := PEncode}

View File

@ -125,7 +125,7 @@ uninstall(HandlerId) ->
name => binary(), name => binary(),
type => topic | clientid | ip_address, type => topic | clientid | ip_address,
id => atom(), id => atom(),
filter => emqx_types:topic() | emqx_types:clienetid() | emqx_trace:ip_address(), filter => emqx_types:topic() | emqx_types:clientid() | emqx_trace:ip_address(),
level => logger:level(), level => logger:level(),
dst => file:filename() | console | unknown dst => file:filename() | console | unknown
} }

View File

@ -42,6 +42,7 @@
stream/0, stream/0,
stream_rank/0, stream_rank/0,
iterator/0, iterator/0,
iterator_id/0,
message_id/0, message_id/0,
message_store_opts/0, message_store_opts/0,
next_result/1, next_result/0, next_result/1, next_result/0,
@ -67,6 +68,9 @@
-type stream_rank() :: {term(), integer()}. -type stream_rank() :: {term(), integer()}.
%% TODO: Not implemented
-type iterator_id() :: term().
-opaque iterator() :: ds_specific_iterator(). -opaque iterator() :: ds_specific_iterator().
-opaque stream() :: ds_specific_stream(). -opaque stream() :: ds_specific_stream().

View File

@ -6,13 +6,7 @@
{vsn, "0.2.17"}, {vsn, "0.2.17"},
{modules, []}, {modules, []},
{registered, []}, {registered, []},
{applications, [kernel, stdlib, emqx_ctl, covertool]}, {applications, [kernel, stdlib, emqx_ctl]},
%% system_monitor is loaded but not booted,
%% emqx_machine.erl makes the decision when to start
%% the app after certain config injection.
%% it's a included_application because otherwise dialyzer
%% would report unknown functions
{included_applications, [system_monitor]},
{mod, {emqx_machine_app, []}}, {mod, {emqx_machine_app, []}},
{env, []}, {env, []},
{licenses, ["Apache-2.0"]}, {licenses, ["Apache-2.0"]},

View File

@ -562,7 +562,8 @@ dialyzer(Config) ->
AppsToExclude = AppNames -- KnownApps, AppsToExclude = AppNames -- KnownApps,
Extra = Extra =
[bcrypt || provide_bcrypt_dep()] ++ [os_mon, system_monitor, covertool] ++
[bcrypt || provide_bcrypt_dep()] ++
[jq || is_jq_supported()] ++ [jq || is_jq_supported()] ++
[quicer || is_quicer_supported()], [quicer || is_quicer_supported()],
NewDialyzerConfig = NewDialyzerConfig =