Kaynağa Gözat

Fix rebar3 dialyzer warnings

Some tricky changes in there but should be okay
pull/1381/head
Fred Hebert 8 yıl önce
ebeveyn
işleme
e85cf555e2
11 değiştirilmiş dosya ile 42 ekleme ve 53 silme
  1. +3
    -3
      src/rebar_app_info.erl
  2. +1
    -3
      src/rebar_config.erl
  3. +4
    -2
      src/rebar_erlc_compiler.erl
  4. +4
    -11
      src/rebar_prv_common_test.erl
  5. +3
    -8
      src/rebar_prv_cover.erl
  6. +1
    -1
      src/rebar_prv_deps.erl
  7. +4
    -10
      src/rebar_prv_eunit.erl
  8. +1
    -1
      src/rebar_prv_shell.erl
  9. +1
    -1
      src/rebar_prv_update.erl
  10. +1
    -1
      src/rebar_prv_xref.erl
  11. +19
    -12
      src/rebar_state.erl

+ 3
- 3
src/rebar_app_info.erl Dosyayı Görüntüle

@ -68,7 +68,7 @@
-export_type([t/0]).
-record(app_info_t, {name :: binary(),
-record(app_info_t, {name :: binary() | undefined,
app_file_src :: file:filename_all() | undefined,
app_file_src_script:: file:filename_all() | undefined,
app_file :: file:filename_all() | undefined,
@ -83,11 +83,11 @@
dep_level=0 :: integer(),
dir :: file:name(),
out_dir :: file:name(),
resource_type :: pkg | src,
resource_type :: pkg | src | undefined,
source :: string() | tuple() | checkout | undefined,
is_lock=false :: boolean(),
is_checkout=false :: boolean(),
valid :: boolean()}).
valid :: boolean() | undefined}).
%%============================================================================
%% types

+ 1
- 3
src/rebar_config.erl Dosyayı Görüntüle

@ -106,9 +106,7 @@ write_lock_file(LockFile, Locks) ->
format_attrs([]) -> [];
format_attrs([{pkg_hash, Vals}|T]) ->
[io_lib:format("{pkg_hash,[~n",[]), format_hashes(Vals), "]}",
maybe_comma(T) | format_attrs(T)];
format_attrs([H|T]) ->
[io_lib:format("~p~s", [H, maybe_comma(T)]) | format_attrs(T)].
maybe_comma(T) | format_attrs(T)].
format_hashes([]) -> [];
format_hashes([{Pkg,Hash}|T]) ->

+ 4
- 2
src/rebar_erlc_compiler.erl Dosyayı Görüntüle

@ -573,9 +573,11 @@ compile_mib(AppInfo) ->
MibToHrlOpts =
case proplists:get_value(verbosity, AllOpts, undefined) of
undefined ->
#options{specific = []};
#options{specific = [],
cwd = rebar_dir:get_cwd()};
Verbosity ->
#options{specific = [{verbosity, Verbosity}]}
#options{specific = [{verbosity, Verbosity}],
cwd = rebar_dir:get_cwd()}
end,
ok = snmpc:mib_to_hrl(Mib, Mib, MibToHrlOpts),
rebar_file_utils:mv(HrlFilename, AppInclude),

+ 4
- 11
src/rebar_prv_common_test.erl Dosyayı Görüntüle

@ -212,7 +212,6 @@ add_hooks(Opts, State) ->
lists:keyreplace(ct_hooks, 1, Opts, {ct_hooks, NewHooks})
end.
select_tests(_, _, {error, _} = Error, _) -> Error;
select_tests(_, _, _, {error, _} = Error) -> Error;
select_tests(State, ProjectApps, CmdOpts, CfgOpts) ->
%% set application env if sys_config argument is provided
@ -293,14 +292,9 @@ compile(State, {ok, _} = Tests) ->
compile(_State, Error) -> Error.
do_compile(State) ->
case rebar_prv_compile:do(State) of
%% successfully compiled apps
{ok, S} ->
ok = maybe_cover_compile(S),
{ok, S};
%% this should look like a compiler error, not an eunit error
Error -> Error
end.
{ok, S} = rebar_prv_compile:do(State),
ok = maybe_cover_compile(S),
{ok, S}.
inject_ct_state(State, {ok, Tests}) ->
Apps = rebar_state:project_apps(State),
@ -308,8 +302,7 @@ inject_ct_state(State, {ok, Tests}) ->
{ok, {NewState, ModdedApps}} ->
test_dirs(NewState, ModdedApps, Tests);
{error, _} = Error -> Error
end;
inject_ct_state(_State, Error) -> Error.
end.
inject_ct_state(State, Tests, [App|Rest], Acc) ->
case inject(rebar_app_info:opts(App), State, Tests) of

+ 3
- 8
src/rebar_prv_cover.erl Dosyayı Görüntüle

@ -88,14 +88,9 @@ analyze(State) ->
%% in order for cover data to be reloaded
%% this maybe breaks if modules have been deleted
%% since code coverage was collected?
case rebar_prv_compile:do(State) of
%% successfully compiled apps
{ok, S} ->
ok = cover_compile(S, apps),
do_analyze(State);
%% this should look like a compiler error, not a cover error
Error -> Error
end.
{ok, S} = rebar_prv_compile:do(State),
ok = cover_compile(S, apps),
do_analyze(State).
do_analyze(State) ->
?INFO("Performing cover analysis...", []),

+ 1
- 1
src/rebar_prv_deps.erl Dosyayı Görüntüle

@ -97,7 +97,7 @@ display_dep(_State, {Name, _Vsn, Source}) when is_tuple(Source) ->
display_dep(_State, {Name, _Vsn, Source, _Opts}) when is_tuple(Source) ->
?CONSOLE("~s* (~s source)", [ec_cnv:to_binary(Name), type(Source)]);
%% Locked
display_dep(State, {Name, Source={pkg, _, Vsn, _}, Level}) when is_integer(Level) ->
display_dep(State, {Name, Source={pkg, _, Vsn}, Level}) when is_integer(Level) ->
DepsDir = rebar_dir:deps_dir(State),
AppDir = filename:join([DepsDir, ec_cnv:to_binary(Name)]),
NeedsUpdate = case rebar_fetch:needs_update(AppDir, Source, State) of

+ 4
- 10
src/rebar_prv_eunit.erl Dosyayı Görüntüle

@ -153,7 +153,6 @@ cfg_tests(State) ->
?PRV_ERROR({badconfig, {"Value `~p' of option `~p' must be a list", {Wrong, eunit_tests}}})
end.
select_tests(_State, _ProjectApps, {error, _} = Error, _) -> Error;
select_tests(_State, _ProjectApps, _, {error, _} = Error) -> Error;
select_tests(State, ProjectApps, [], []) -> {ok, default_tests(State, ProjectApps)};
select_tests(_State, _ProjectApps, [], Tests) -> {ok, Tests};
@ -316,14 +315,9 @@ inject_test_dir(Opts, Dir) ->
compile({error, _} = Error) -> Error;
compile(State) ->
case rebar_prv_compile:do(State) of
%% successfully compiled apps
{ok, S} ->
ok = maybe_cover_compile(S),
{ok, S};
%% this should look like a compiler error, not an eunit error
Error -> Error
end.
{ok, S} = rebar_prv_compile:do(State),
ok = maybe_cover_compile(S),
{ok, S}.
validate_tests(State, {ok, Tests}) ->
gather_tests(fun(Elem) -> validate(State, Elem) end, Tests, []);
@ -453,7 +447,7 @@ translate(State, [], {dir, Dir}) ->
translate(State, [], {file, FilePath}) ->
Dir = filename:dirname(FilePath),
File = filename:basename(FilePath),
case rebar_file_utils:path_from_ancestor(Dir, rebar_app_info:dir(State)) of
case rebar_file_utils:path_from_ancestor(Dir, rebar_state:dir(State)) of
{ok, Path} -> {file, filename:join([rebar_dir:base_dir(State), "extras", Path, File])};
%% not relative, leave as is
{error, badparent} -> {file, FilePath}

+ 1
- 1
src/rebar_prv_shell.erl Dosyayı Görüntüle

@ -120,7 +120,7 @@ info() ->
setup_shell() ->
OldUser = kill_old_user(),
%% Test for support here
NewUser = try erlang:open_port({spawn,'tty_sl -c -e';}, []) of
NewUser = try erlang:open_port({spawn,"tty_sl -c -e";}, []) of
Port when is_port(Port) ->
true = port_close(Port),
setup_new_shell()

+ 1
- 1
src/rebar_prv_update.erl Dosyayı Görüntüle

@ -236,7 +236,7 @@ cmp_(BestMatch, MinVsn, [Vsn | R], DepsListAcc, Dep, CmpFun) ->
%% We need to treat this differently since we want a version that is LOWER but
%% the higest possible one.
cmpl({_Pkg, _PkgVsn, Dep} = Dep1, Vsn, HexRegistry, State, DepsListAcc, CmpFun) ->
cmpl({_Pkg, _PkgVsn, Dep, _App} = Dep1, Vsn, HexRegistry, State, DepsListAcc, CmpFun) ->
{ok, Vsns} = rebar_packages:find_all(Dep, HexRegistry, State),
cmpl_(undefined, Vsn, Vsns, DepsListAcc, Dep1, CmpFun).

+ 1
- 1
src/rebar_prv_xref.erl Dosyayı Görüntüle

@ -273,7 +273,7 @@ find_function_source(M, F, A, Bin) ->
AbstractCode = beam_lib:chunks(Bin, [abstract_code]),
{ok, {M, [{abstract_code, {raw_abstract_v1, Code}}]}} = AbstractCode,
%% Extract the original source filename from the abstract code
[{attribute, 1, file, {Source, _}} | _] = Code,
[{attribute, _, file, {Source, _}} | _] = Code,
%% Extract the line number for a given function def
Fn = [E || E <- Code,
safe_element(1, E) == function,

+ 19
- 12
src/rebar_state.erl Dosyayı Görüntüle

@ -59,7 +59,7 @@
command_args = [],
command_parsed_args = {[], []},
current_app :: rebar_app_info:t(),
current_app :: undefined | rebar_app_info:t(),
project_apps = [] :: [rebar_app_info:t()],
deps_to_build = [] :: [rebar_app_info:t()],
all_plugin_deps = [] :: [rebar_app_info:t()],
@ -424,17 +424,24 @@ create_logic_providers(ProviderModules, State0) ->
to_list(#state_t{} = State) ->
Fields = record_info(fields, state_t),
Values = tl(tuple_to_list(State)),
DictSz = tuple_size(dict:new()),
lists:zip(Fields, [reformat(I, DictSz) || I <- Values]).
reformat({K,V}, DSz) when is_list(V) ->
{K, [reformat(I, DSz) || I <- V]};
reformat(V, DSz) when is_tuple(V), element(1,V) =:= dict, tuple_size(V) =:= DSz ->
[reformat(I, DSz) || I <- dict:to_list(V)];
reformat({K,V}, DSz) when is_tuple(V), element(1,V) =:= dict, tuple_size(V) =:= DSz ->
{K, [reformat(I, DSz) || I <- dict:to_list(V)]};
reformat(Other, _DSz) ->
Other.
lists:zip(Fields, [reformat(I) || I <- Values]).
reformat({K,V}) when is_list(V) ->
{K, [reformat(I) || I <- V]};
reformat({K,V}) ->
try
{K, [reformat(I) || I <- dict:to_list(V)]}
catch
error:{badrecord,dict} ->
{K,V}
end;
reformat(V) ->
try
[reformat(I) || I <- dict:to_list(V)]
catch
error:{badrecord,dict} ->
V
end.
%% ===================================================================
%% Internal functions

Yükleniyor…
İptal
Kaydet