Skip to content

Commit

Permalink
chore: add dialyzer for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwencool committed Oct 21, 2024
1 parent d9ad948 commit 4eb8941
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ jobs:
run: rebar3 compile
- name: xref
run: rebar3 xref
- name: dialyzer
run: rebar3 dialyzer

2 changes: 1 addition & 1 deletion src/observer_cli_application.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

%% @doc List application info

-spec start(ViewOpts) -> no_return when ViewOpts :: view_opts().
-spec start(ViewOpts) -> quit when ViewOpts :: view_opts().
start(#view_opts{app = App, auto_row = AutoRow} = ViewOpts) ->
Pid = spawn_link(fun() ->
?output(?CLEAR),
Expand Down
4 changes: 1 addition & 3 deletions src/observer_cli_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ uptime() ->
[?W(?GREEN, Time, 16)].

%% @doc 0.982342 -> 98.23%, 1 -> 100.0%
-spec to_percent(float()) -> string().
to_percent(Float) when Float < 0.1 -> [$0, erlang:float_to_list(Float * 100, [{decimals, 2}]), $%];
to_percent(Float) when Float < 1 -> [erlang:float_to_list(Float * 100, [{decimals, 2}]), $%];
to_percent(undefined) -> "******";
to_percent(_) -> "100.0%".

-spec to_list(term()) -> list().
to_list(Atom) when is_atom(Atom) -> atom_to_list(Atom);
to_list(Integer) when is_integer(Integer) -> integer_to_list(Integer);
to_list(Pid) when is_pid(Pid) -> erlang:pid_to_list(Pid);
Expand Down Expand Up @@ -273,7 +271,7 @@ to_pid(Str) ->
quit
end.

-spec next_redraw(reference(), pos_integer()) -> reference().
-spec next_redraw(reference() | ?INIT_TIME_REF, pos_integer()) -> reference().
next_redraw(LastTimeRef, Interval) ->
LastTimeRef =/= ?INIT_TIME_REF andalso erlang:cancel_timer(LastTimeRef),
erlang:send_after(Interval, self(), redraw).
Expand Down
3 changes: 3 additions & 0 deletions src/observer_cli_mnesia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ get_table_list(HideSys, Attr) ->
_ -> get_table_list2(Owner, HideSys, Attr)
end.

-dialyzer([{nowarn_function, [get_table_list2/3]}]).
get_table_list2(Owner, HideSys, Attr) ->
{registered_name, RegName} = process_info(Owner, registered_name),
WordSize = erlang:system_info(wordsize),
Expand All @@ -213,6 +214,8 @@ get_table_list2(Owner, HideSys, Attr) ->
end,
lists:foldl(CollectFun, [], mnesia:system_info(tables)).

-dialyzer([{nowarn_function, [with_storage_type/2]}]).

with_storage_type(Id, Tab0) ->
Storage = mnesia:table_info(Id, storage_type),
with_storage_type(Id, Storage, Tab0).
Expand Down
4 changes: 1 addition & 3 deletions src/observer_cli_plugin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ manager(ChildPid, SheetCache, ViewOpts) ->
start(ViewOpts#view_opts{plug = PlugOpts#plug{plugs = NewPlugs}});
{error, _} ->
manager(ChildPid, SheetCache, ViewOpts)
end;
_ ->
manager(ChildPid, SheetCache, ViewOpts)
end
end.

update_plugins(CurIndex, Lists, UpdateItems) ->
Expand Down
6 changes: 6 additions & 0 deletions src/observer_cli_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

-include("observer_cli.hrl").

-dialyzer([
{nowarn_function, [
render_worker/7, render_reduction_memory/4, get_chart_format/1, chart_format/2
]}
]).

-export([start/3]).

%% lists:foldl(fun(_X, Acc) -> queue:in('NaN', Acc) end, queue:new(), lists:seq(1, 5))
Expand Down
2 changes: 1 addition & 1 deletion src/observer_cli_system.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ get_address(Info) ->
get_dist_queue_size(Node) ->
case ets:lookup(sys_dist, Node) of
[] ->
0;
not_found;
[Dist] ->
ConnId = element(3, Dist),
{ok, _, _, Size} = erlang:dist_get_stat(ConnId),
Expand Down

0 comments on commit 4eb8941

Please sign in to comment.