Skip to content

Commit a8207bb

Browse files
committed
update type specs to pass dialyzer check
1 parent 0ce880d commit a8207bb

9 files changed

+41
-5
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
logs
2+
*.beam
3+

Diff for: Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
all: dialyze
2+
3+
build:
4+
@./rebar compile
5+
6+
ct: clean build
7+
@./rebar ct
8+
9+
dialyze: build
10+
@./rebar dialyze
11+
12+
doc:
13+
@./rebar doc
14+
15+
clean:
16+
@./rebar clean
17+
@find . -name '*.beam' -exec rm -f '{}' ';'
18+
@rm -f doc/*.html doc/*.png doc/*.css doc/edoc-info
19+
@rm -rf logs/
20+
21+
.PHONY: all build ct dialyze doc clean
22+

Diff for: src/zfor_app.erl

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
% @spec start(
1111
% StartType::('normal' | {'takeover', Node::node()} | {'failover', Node::node()}),
1212
% StartArgs::term()
13-
% ) -> {'ok', pid()} | {'ok', pid(), term()} | {'error', term()}
13+
% ) -> {'ok', pid()} | {'error', term()}
1414
% @end
1515
% {{{
1616
-spec start(
1717
StartType::('normal' | {'takeover', Node::node()} | {'failover', Node::node()}),
1818
StartArgs::term()
19-
) -> {'ok', pid()} | {'ok', pid(), term()} | {'error', term()}.
19+
) -> {'ok', pid()} | {'error', term()}.
2020

2121
start(_Type, _Args) ->
2222
% 从应用配置参数环境中读取conf_path参数

Diff for: src/zfor_httpclient.erl

+12-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ request(Req) ->
102102
% @doc Receive and parse HTTP responses.
103103
% @end
104104
% {{{
105-
-spec recv_http_resp(Sock::pid(), Buf::binary()) ->
105+
-spec recv_http_resp(Sock::port(), Buf::binary()) ->
106106
{ok,
107107
{
108108
{Version::string(), Status::integer(), Reason::string()},
@@ -138,6 +138,15 @@ recv_http_resp(Sock, Buf) ->
138138
% @doc Receive and parse response headers and body
139139
% @end
140140
% {{{
141+
-spec recv_http_header(Sock::port(), Res::tuple(), Buf::binary()) ->
142+
{ok,
143+
{
144+
{Version::string(), Status::integer(), Reason::string()},
145+
[{Field::string(), Value::string()}],
146+
Body::string()
147+
}
148+
} | {error, Reason::term()}.
149+
141150
recv_http_header(Sock, {ok, {{Ver, Code, Reason}, Headers, Body}} = Res, Buf) ->
142151
case erlang:decode_packet(httph, Buf, []) of
143152
{error, DReason} -> {error, DReason};
@@ -180,6 +189,8 @@ recv_http_header(Sock, {ok, {{Ver, Code, Reason}, Headers, Body}} = Res, Buf) ->
180189
% @doc Receive response body.
181190
% @end
182191
% {{{
192+
-spec recv_http_body(Sock::port(), Len::integer(), LB::list(binary())) -> binary().
193+
183194
recv_http_body(_, N, LB) when N =< 0 ->
184195
iolist_to_binary(lists:reverse(LB));
185196

Diff for: src/zfor_main.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ system_continue(Parent, DbgOpts, State) ->
183183
),
184184
loop(Parent, NewDbgOpts, State).
185185

186-
-spec system_terminate(Reason :: term(), Parent :: pid(), DbgOpts :: [term()], State :: server_state()) -> true.
186+
-spec system_terminate(Reason :: term(), Parent :: pid(), DbgOpts :: [term()], State :: server_state()) -> none().
187187
system_terminate(Reason, _Parent, DbgOpts, State) ->
188188
sys:handle_debug(DbgOpts, {?MODULE, debug_output}, ?MODULE, {"service terminating", State}),
189189
stop_all_proc(State),

Diff for: src/zfor_sup.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
start_link(ConfPath) ->
1010
supervisor:start_link({'local', ?ZFOR_SUPERVISOR_SRVNAME}, ?MODULE, ConfPath).
1111

12-
-spec init(ConfPath::string()) -> {'ok', {{atom(), integer(), integer()}, [child_spec()]}} | 'ignore'.
12+
-spec init(ConfPath::string()) -> {'ok', {{atom(), integer(), integer()}, [child_spec()]}}.
1313
init(ConfPath) ->
1414
{ok,{
1515
% 重启策略为one_for_one,即哪个服务死掉就重启对应的服务

Diff for: test/zfor_config_SUITE.beam

-8.34 KB
Binary file not shown.

Diff for: test/zfor_server_SUITE.beam

-4.34 KB
Binary file not shown.

Diff for: test/zfor_util_SUITE.beam

-5.55 KB
Binary file not shown.

0 commit comments

Comments
 (0)