瀏覽代碼

fix dialyzer warnings, except 'no local return' warnings

pull/696/head
Tristan Sloughter 9 年之前
父節點
當前提交
6fde1748b9
共有 11 個文件被更改,包括 36 次插入51 次删除
  1. +1
    -1
      src/rebar_agent.erl
  2. +5
    -10
      src/rebar_app_discover.erl
  3. +2
    -2
      src/rebar_core.erl
  4. +1
    -1
      src/rebar_prv_deps.erl
  5. +9
    -23
      src/rebar_prv_install_deps.erl
  6. +3
    -7
      src/rebar_prv_packages.erl
  7. +1
    -1
      src/rebar_prv_shell.erl
  8. +5
    -0
      src/rebar_prv_update.erl
  9. +1
    -1
      src/rebar_prv_xref.erl
  10. +7
    -4
      src/rebar_state.erl
  11. +1
    -1
      src/rebar_utils.erl

+ 1
- 1
src/rebar_agent.erl 查看文件

@ -104,7 +104,7 @@ refresh_paths(RState) ->
ok;
{ok, _} ->
?DEBUG("reloading ~p from ~s", [Modules, Path]),
code:replace_path(Name, Path),
code:replace_path(App, Path),
[begin code:purge(M), code:delete(M), code:load_file(M) end
|| M <- Modules]
end

+ 5
- 10
src/rebar_app_discover.erl 查看文件

@ -138,7 +138,7 @@ find_app(AppDir, Validate) ->
app_dir(AppFile) ->
filename:join(rebar_utils:droplast(filename:split(filename:dirname(AppFile)))).
-spec create_app_info(file:name(), file:name()) -> rebar_app_info:t() | {error, term()}.
-spec create_app_info(file:name(), file:name()) -> rebar_app_info:t().
create_app_info(AppDir, AppFile) ->
[{application, AppName, AppDetails}] = rebar_config:consult_app_file(AppFile),
AppVsn = proplists:get_value(vsn, AppDetails),
@ -208,16 +208,11 @@ try_handle_app_src_file(_, _AppDir, _AppSrcFile, valid) ->
try_handle_app_src_file(_, AppDir, [File], Validate) when Validate =:= invalid
; Validate =:= all ->
AppInfo = create_app_info(AppDir, File),
case AppInfo of
{error, Reason} ->
throw({error, {invalid_app_file, File, Reason}});
case filename:extension(File) of
".script" ->
{true, rebar_app_info:app_file_src_script(AppInfo, File)};
_ ->
case filename:extension(File) of
".script" ->
{true, rebar_app_info:app_file_src_script(AppInfo, File)};
_ ->
{true, rebar_app_info:app_file_src(AppInfo, File)}
end
{true, rebar_app_info:app_file_src(AppInfo, File)}
end;
try_handle_app_src_file(_, _AppDir, Other, _Validate) ->
throw({error, {multiple_app_files, Other}}).

+ 2
- 2
src/rebar_core.erl 查看文件

@ -61,7 +61,7 @@ process_namespace(State, Command) ->
{ok, rebar_state:namespace(State, default), Command}
end.
-spec process_command(rebar_state:t(), atom()) -> {ok, rebar_state:t()} | {error, string()}.
-spec process_command(rebar_state:t(), atom()) -> {ok, rebar_state:t()} | {error, string()} | {error, {module(), any()}}.
process_command(State, Command) ->
%% ? rebar_prv_install_deps:setup_env(State),
Providers = rebar_state:providers(State),
@ -103,7 +103,7 @@ process_command(State, Command) ->
end
end.
-spec do([{atom(), atom()}], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
-spec do([{atom(), atom()}], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()} | {error, {module(), any()}}.
do([], State) ->
{ok, State};
do([ProviderName | Rest], State) ->

+ 1
- 1
src/rebar_prv_deps.erl 查看文件

@ -33,7 +33,7 @@ do(State) ->
true ->
{_Packages, Graph} = rebar_state:packages(State),
List = merge_deps_per_profile(State),
{_SrcDeps, PkgDeps} = rebar_prv_install_deps:parse_deps("", List, State, [], 0),
{_SrcDeps, PkgDeps} = rebar_prv_install_deps:parse_deps(<<"";>>;, List, State, [], 0),
rebar_digraph:print_solution(Graph, PkgDeps),
{ok, State};
false ->

+ 9
- 23
src/rebar_prv_install_deps.erl 查看文件

@ -289,7 +289,7 @@ package_to_app(DepsDir, Packages, {Name, Vsn, Level}, IsLock, State) ->
rebar_app_info:state(AppInfo1, AppState1)
end.
-spec update_src_deps(atom(), non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary()), list()) -> {rebar_state:t(), list(), list(), sets:set(binary())}.
-spec update_src_deps(atom(), non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary()), list()) -> {list(), list(), list(), rebar_state:t(), sets:set(binary()), list()}.
update_src_deps(Profile, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen, Locks) ->
lists:foldl(
fun(AppInfo, {SrcDepsAcc, PkgDepsAcc, SrcAppsAcc, StateAcc, SeenAcc, LocksAcc}) ->
@ -371,7 +371,7 @@ handle_dep(AppInfo, Profile, SrcDeps, PkgDeps, SrcApps, Level, State, Locks) ->
,NewLocks}.
-spec handle_dep(rebar_state:t(), atom(), file:filename_all(), rebar_app_info:t(), list(), integer()) ->
{rebar_app_info:t(), [rebar_app_info:t()], [pkg_dep()], [integer()]}.
{rebar_app_info:t(), [rebar_app_info:t()], [pkg_dep()], [integer()], rebar_state:t()}.
handle_dep(State, Profile, DepsDir, AppInfo, Locks, Level) ->
Profiles = rebar_state:current_profiles(State),
Name = rebar_app_info:name(AppInfo),
@ -413,13 +413,9 @@ maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) ->
false ->
case rebar_app_discover:find_app(AppDir, all) of
false ->
case fetch_app(AppInfo, AppDir, State) of
true ->
maybe_symlink_default(State, Profile, AppDir, AppInfo),
{true, update_app_info(AppDir, AppInfo)};
Other ->
{Other, AppInfo}
end;
true = fetch_app(AppInfo, AppDir, State),
maybe_symlink_default(State, Profile, AppDir, AppInfo),
{true, update_app_info(AppDir, AppInfo)};
{true, AppInfo1} ->
%% Preserve the state we created with overrides
AppState = rebar_app_info:state(AppInfo),
@ -477,7 +473,7 @@ make_relative_to_root(State, Path) when is_list(Path) ->
Root = rebar_dir:root_dir(State),
rebar_dir:make_relative_path(Path, Root).
-spec parse_deps(binary(), list(), rebar_state:t(), list(), integer()) -> {[rebar_app_info:t()], [pkg_dep()]}.
-spec parse_deps(binary(), list(), rebar_state:t(), list(), integer()) -> {[rebar_app_info:t()], [tuple()]}.
parse_deps(DepsDir, Deps, State, Locks, Level) ->
lists:foldl(fun(Dep, Acc) ->
Name = case Dep of
@ -575,12 +571,7 @@ new_dep(DepsDir, Name, Vsn, Source, IsLock, State) ->
fetch_app(AppInfo, AppDir, State) ->
?INFO("Fetching ~s (~p)", [rebar_app_info:name(AppInfo), rebar_app_info:source(AppInfo)]),
Source = rebar_app_info:source(AppInfo),
case rebar_fetch:download_source(AppDir, Source, State) of
true ->
true;
Error ->
throw(Error)
end.
true = rebar_fetch:download_source(AppDir, Source, State).
%% This is called after the dep has been downloaded and unpacked, if it hadn't been already.
%% So this is the first time for newly downloaded apps that its .app/.app.src data can
@ -602,12 +593,7 @@ maybe_upgrade(AppInfo, AppDir, Upgrade, State) ->
case rebar_fetch:needs_update(AppDir, Source, State) of
true ->
?INFO("Upgrading ~s", [rebar_app_info:name(AppInfo)]),
case rebar_fetch:download_source(AppDir, Source, State) of
true ->
true;
Error ->
throw(Error)
end;
true = rebar_fetch:download_source(AppDir, Source, State);
false ->
case Upgrade of
true ->
@ -621,7 +607,7 @@ maybe_upgrade(AppInfo, AppDir, Upgrade, State) ->
false
end.
-spec parse_goal(binary(), binary()) -> pkg_dep().
-spec parse_goal(binary(), binary()) -> {binary(), binary()} | {binary(), binary(), binary()}.
parse_goal(Name, Constraint) ->
case re:run(Constraint, "([^\\d]*)(\\d.*)", [{capture, [1,2], binary}]) of
{match, [<<>>, Vsn]} ->

+ 3
- 7
src/rebar_prv_packages.erl 查看文件

@ -27,13 +27,9 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
case rebar_packages:get_packages(State) of
{Dict, _} ->
print_packages(Dict),
{ok, State};
error ->
?PRV_ERROR(load_registry_fail)
end.
{Dict, _} = rebar_packages:get_packages(State),
print_packages(Dict),
{ok, State}.
-spec format_error(any()) -> iolist().
format_error(load_registry_fail) ->

+ 1
- 1
src/rebar_prv_shell.erl 查看文件

@ -274,7 +274,7 @@ find_config_relx(State) ->
consult_config(State, Filename)
end.
-spec consult_config(rebar_state:t(), string()) -> {ok, [tuple()]}|{error, tuple()}.
-spec consult_config(rebar_state:t(), string()) -> [tuple()].
consult_config(State, Filename) ->
Fullpath = filename:join(rebar_dir:root_dir(State), Filename),
?DEBUG("Loading configuration from ~p", [Fullpath]),

+ 5
- 0
src/rebar_prv_update.erl 查看文件

@ -15,6 +15,10 @@
-define(PROVIDER, update).
-define(DEPS, []).
%% Ignore warning of digraph opqaque type when running dialyzer
-dialyzer({no_opaque, do/1}).
-dialyzer({no_opaque, write_registry/3}).
%% ===================================================================
%% Public API
%% ===================================================================
@ -63,6 +67,7 @@ do(State) ->
format_error(package_index_write) ->
"Failed to write package index.".
-spec write_registry(rebar_dict(), {digraph, ets:tid(), ets:tid(), ets:tid(), any()}, rebar_state:t()) -> ok | {error, atom()}.
write_registry(Dict, {digraph, Edges, Vertices, Neighbors, _}, State) ->
RegistryDir = rebar_packages:package_dir(State),
filelib:ensure_dir(filename:join(RegistryDir, "dummy")),

+ 1
- 1
src/rebar_prv_xref.erl 查看文件

@ -88,7 +88,7 @@ desc() ->
" - (\"mod\":\".*foo\"/\"4\"))",[]}]}
]).
-spec prepare(rebar_state:t()) -> {[file:filename()], [atom()]}.
-spec prepare(rebar_state:t()) -> [atom()].
prepare(State) ->
{ok, _} = xref:start(xref),
ok = xref:set_library_path(xref, code_path(State)),

+ 7
- 4
src/rebar_state.erl 查看文件

@ -171,7 +171,7 @@ default(State, Opts) ->
format_error({profile_not_list, Profile, Other}) ->
io_lib:format("Profile config must be a list but for profile '~p' config given as:~n~p", [Profile, Other]).
-spec has_all_artifacts(rebar_app_info:t()) -> true | providers:error().
-spec has_all_artifacts(#state_t{}) -> true | {false, file:filename()}.
has_all_artifacts(State) ->
Artifacts = rebar_state:get(State, artifacts, []),
Dir = rebar_dir:base_dir(State),
@ -188,6 +188,7 @@ all(Dir, [File|Artifacts]) ->
all(Dir, Artifacts)
end.
-spec code_paths(#state_t{}, atom()) -> [file:filename()].
code_paths(#state_t{code_paths=CodePaths}, Key) ->
case dict:find(Key, CodePaths) of
{ok, CodePath} ->
@ -196,9 +197,11 @@ code_paths(#state_t{code_paths=CodePaths}, Key) ->
[]
end.
-spec code_paths(#state_t{}, atom(), [file:filename()]) -> #state_t{}.
code_paths(State=#state_t{code_paths=CodePaths}, Key, CodePath) ->
State#state_t{code_paths=dict:store(Key, CodePath, CodePaths)}.
-spec update_code_paths(#state_t{}, atom(), [file:filename()]) -> #state_t{}.
update_code_paths(State=#state_t{code_paths=CodePaths}, Key, CodePath) ->
case dict:is_key(Key, CodePaths) of
true ->
@ -451,15 +454,15 @@ registry(#state_t{registry=Registry}) ->
registry(State, Registry) ->
State#state_t{registry=Registry}.
-spec resources(t()) -> rebar_resource:resource().
-spec resources(t()) -> [{rebar_resource:type(), module()}].
resources(#state_t{resources=Resources}) ->
Resources.
-spec resources(t(), [rebar_resource:resource()]) -> t().
-spec resources(t(), [{rebar_resource:type(), module()}]) -> t().
resources(State, NewResources) ->
State#state_t{resources=NewResources}.
-spec add_resource(t(), rebar_resource:resource()) -> t().
-spec add_resource(t(), {rebar_resource:type(), module()}) -> t().
add_resource(State=#state_t{resources=Resources}, Resource) ->
State#state_t{resources=[Resource | Resources]}.

+ 1
- 1
src/rebar_utils.erl 查看文件

@ -683,7 +683,7 @@ update_code(Paths) ->
code:add_patha(Path),
ok;
{ok, Modules} ->
code:replace_path(Name, Path),
code:replace_path(App, Path),
[begin code:purge(M), code:delete(M) end || M <- Modules]
end
end, Paths).

Loading…
取消
儲存