diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-08-08 14:17:03 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-08-08 14:17:03 -0500 |
commit | 6fde1748b9c7a67db1dbd1fb051d630c79656b3a (patch) | |
tree | 405637c328abc04aa3dce2e9bebe4d2a7b5e1c2e /src | |
parent | 1001eefc2b0f0979c1a07fc309625ee04df60910 (diff) |
fix dialyzer warnings, except 'no local return' warnings
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_agent.erl | 2 | ||||
-rw-r--r-- | src/rebar_app_discover.erl | 15 | ||||
-rw-r--r-- | src/rebar_core.erl | 4 | ||||
-rw-r--r-- | src/rebar_prv_deps.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 32 | ||||
-rw-r--r-- | src/rebar_prv_packages.erl | 10 | ||||
-rw-r--r-- | src/rebar_prv_shell.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 5 | ||||
-rw-r--r-- | src/rebar_prv_xref.erl | 2 | ||||
-rw-r--r-- | src/rebar_state.erl | 11 | ||||
-rw-r--r-- | src/rebar_utils.erl | 2 |
11 files changed, 36 insertions, 51 deletions
diff --git a/src/rebar_agent.erl b/src/rebar_agent.erl index dc45dcf..2b69812 100644 --- a/src/rebar_agent.erl +++ b/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 diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index c5a79a6..3b34539 100644 --- a/src/rebar_app_discover.erl +++ b/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}}). diff --git a/src/rebar_core.erl b/src/rebar_core.erl index f097429..ba82a59 100644 --- a/src/rebar_core.erl +++ b/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) -> diff --git a/src/rebar_prv_deps.erl b/src/rebar_prv_deps.erl index dc356a8..9dc5346 100644 --- a/src/rebar_prv_deps.erl +++ b/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 -> diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index b590d03..72350d6 100644 --- a/src/rebar_prv_install_deps.erl +++ b/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]} -> diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl index 9a40734..880d4a6 100644 --- a/src/rebar_prv_packages.erl +++ b/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) -> diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl index 431b3e2..d965e1d 100644 --- a/src/rebar_prv_shell.erl +++ b/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]), diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 64fe65e..50ae2a0 100644 --- a/src/rebar_prv_update.erl +++ b/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")), diff --git a/src/rebar_prv_xref.erl b/src/rebar_prv_xref.erl index 623e946..f600273 100644 --- a/src/rebar_prv_xref.erl +++ b/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)), diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 8c43496..59a9588 100644 --- a/src/rebar_state.erl +++ b/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]}. diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index c7128fc..a61ae37 100644 --- a/src/rebar_utils.erl +++ b/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). |