diff --git a/.travis.yml b/.travis.yml index adef0f3cd..2557513d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ before_install: script: - make dep-vsn-check - make rebar-compile + - make rebar-xref - make rebar-eunit - make rebar-ct - make rebar-cover diff --git a/Makefile b/Makefile index c5033df7b..e061066b4 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,9 @@ cuttlefish: rebar-deps mv _build/default/lib/cuttlefish/cuttlefish ./cuttlefish; \ fi +rebar-xref: + @rebar3 xref + rebar-deps: @rebar3 get-deps diff --git a/src/emqx_config.erl b/src/emqx_config.erl index 2b96f88fc..435ebaea7 100644 --- a/src/emqx_config.erl +++ b/src/emqx_config.erl @@ -66,19 +66,19 @@ reload(_App) -> ok. -spec(write(atom(), list(env())) -> ok | {error, term()}). -write(App, Terms) -> - Configs = lists:map(fun({Key, Val}) -> - {cuttlefish_variable:tokenize(binary_to_list(Key)), binary_to_list(Val)} - end, Terms), - Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]), - Schema = cuttlefish_schema:files([Path]), - case cuttlefish_generator:map(Schema, Configs) of - [{App, Configs1}] -> - emqx_cli_config:write_config(App, Configs), - lists:foreach(fun({Key, Val}) -> application:set_env(App, Key, Val) end, Configs1); - _ -> - error - end. +write(_App, _Terms) -> ok. + % Configs = lists:map(fun({Key, Val}) -> + % {cuttlefish_variable:tokenize(binary_to_list(Key)), binary_to_list(Val)} + % end, Terms), + % Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]), + % Schema = cuttlefish_schema:files([Path]), + % case cuttlefish_generator:map(Schema, Configs) of + % [{App, Configs1}] -> + % emqx_cli_config:write_config(App, Configs), + % lists:foreach(fun({Key, Val}) -> application:set_env(App, Key, Val) end, Configs1); + % _ -> + % error + % end. -spec(dump(atom(), list(env())) -> ok | {error, term()}). dump(_App, _Terms) -> @@ -86,47 +86,47 @@ dump(_App, _Terms) -> ok. -spec(set(atom(), list(), list()) -> ok). -set(App, Par, Val) -> - emqx_cli_config:run(["config", - "set", - lists:concat([Par, "=", Val]), - lists:concat(["--app=", App])]). +set(_App, _Par, _Val) -> ok. + % emqx_cli_config:run(["config", + % "set", + % lists:concat([Par, "=", Val]), + % lists:concat(["--app=", App])]). -spec(get(atom(), list()) -> undefined | {ok, term()}). -get(App, Par) -> - case emqx_cli_config:get_cfg(App, Par) of - undefined -> undefined; - Val -> {ok, Val} - end. +get(_App, _Par) -> error(no_impl). + % case emqx_cli_config:get_cfg(App, Par) of + % undefined -> undefined; + % Val -> {ok, Val} + % end. -spec(get(atom(), list(), atom()) -> term()). -get(App, Par, Def) -> - emqx_cli_config:get_cfg(App, Par, Def). +get(_App, _Par, _Def) -> error(no_impl). + % emqx_cli_config:get_cfg(App, Par, Def). -read_(App) -> - Configs = emqx_cli_config:read_config(App), - Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]), - case filelib:is_file(Path) of - false -> - []; - true -> - {_, Mappings, _} = cuttlefish_schema:files([Path]), - OptionalCfg = lists:foldl(fun(Map, Acc) -> - Key = cuttlefish_mapping:variable(Map), - case proplists:get_value(Key, Configs) of - undefined -> - [{cuttlefish_variable:format(Key), "", cuttlefish_mapping:doc(Map), false} | Acc]; - _ -> Acc - end - end, [], Mappings), - RequiredCfg = lists:foldl(fun({Key, Val}, Acc) -> - case lists:keyfind(Key, 2, Mappings) of - false -> Acc; - Map -> - [{cuttlefish_variable:format(Key), Val, cuttlefish_mapping:doc(Map), true} | Acc] - end - end, [], Configs), - RequiredCfg ++ OptionalCfg - end. +read_(_App) -> error(no_impl). + % Configs = emqx_cli_config:read_config(App), + % Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]), + % case filelib:is_file(Path) of + % false -> + % []; + % true -> + % {_, Mappings, _} = cuttlefish_schema:files([Path]), + % OptionalCfg = lists:foldl(fun(Map, Acc) -> + % Key = cuttlefish_mapping:variable(Map), + % case proplists:get_value(Key, Configs) of + % undefined -> + % [{cuttlefish_variable:format(Key), "", cuttlefish_mapping:doc(Map), false} | Acc]; + % _ -> Acc + % end + % end, [], Mappings), + % RequiredCfg = lists:foldl(fun({Key, Val}, Acc) -> + % case lists:keyfind(Key, 2, Mappings) of + % false -> Acc; + % Map -> + % [{cuttlefish_variable:format(Key), Val, cuttlefish_mapping:doc(Map), true} | Acc] + % end + % end, [], Configs), + % RequiredCfg ++ OptionalCfg + % end. diff --git a/src/emqx_mod_subscription.erl b/src/emqx_mod_subscription.erl index 48edac2c4..aed7f5af2 100644 --- a/src/emqx_mod_subscription.erl +++ b/src/emqx_mod_subscription.erl @@ -36,7 +36,7 @@ on_session_created(#{client_id := ClientId}, SessAttrs, Topics) -> emqx_session:subscribe(self(), [{Replace(Topic), #{qos => QoS}} || {Topic, QoS} <- Topics]). unload(_) -> - emqx_hooks:delete('session.created', fun ?MODULE:on_session_created/3). + emqx_hooks:del('session.created', fun ?MODULE:on_session_created/3). %%-------------------------------------------------------------------- %% Internal functions