Browse Source

Prevent warnings on wrongly -spec.(_)'ed types

(some are not "wrong" per se, but incomplete)
pull/2412/head
Paulo F. Oliveira 4 years ago
parent
commit
44ffb45f17
8 changed files with 30 additions and 26 deletions
  1. +3
    -3
      src/rebar.hrl
  2. +1
    -1
      src/rebar_api.erl
  3. +11
    -11
      src/rebar_app_info.erl
  4. +6
    -4
      src/rebar_app_utils.erl
  5. +1
    -1
      src/rebar_paths.erl
  6. +4
    -3
      src/rebar_pkg_resource.erl
  7. +2
    -1
      src/rebar_resource_v2.erl
  8. +2
    -2
      src/rebar_utils.erl

+ 3
- 3
src/rebar.hrl View File

@ -39,14 +39,14 @@
%% the package record is used in a select match spec which upsets dialyzer
%% this is the suggested workaround from Tobias
%% http://erlang.org/pipermail/erlang-questions/2009-February/041445.html
-type ms_field() :: '$1' | '_'.
-type ms_field() :: '$1' | '_' | {'$1', '$2'}.
%% TODO: change package and requirement keys to be required (:=) after dropping support for OTP-18
-record(package, {key :: {unicode:unicode_binary() | ms_field(), unicode:unicode_binary() | ms_field(),
-record(package, {key :: {unicode:unicode_binary() | ms_field(), unicode:unicode_binary() | ms_field() | ec_semver:semver(),
unicode:unicode_binary() | ms_field()},
inner_checksum :: binary() | ms_field(),
outer_checksum :: binary() | ms_field(),
retired :: boolean() | ms_field(),
retired :: boolean() | ms_field() | #{reason := atom()},
dependencies :: [#{package => unicode:unicode_binary(),
requirement => unicode:unicode_binary()}] | ms_field()}).

+ 1
- 1
src/rebar_api.erl View File

@ -103,6 +103,6 @@ processing_base_dir(State) ->
%% @doc returns the SSL options adequate for the project based on
%% its configuration, including for validation of certs.
-spec ssl_opts(string()) -> [term()].
-spec ssl_opts(string() | binary()) -> [term()].
ssl_opts(Url) ->
rebar_utils:ssl_opts(Url).

+ 11
- 11
src/rebar_app_info.erl View File

@ -87,9 +87,9 @@
app_file_src :: file:filename_all() | undefined,
app_file_src_script:: file:filename_all() | undefined,
app_file :: file:filename_all() | undefined,
original_vsn :: binary() | undefined,
vsn :: binary() | undefined,
parent=root :: binary() | root,
original_vsn :: binary() | string() | undefined,
vsn :: binary() | string() | undefined,
parent=root :: binary() | root | string(),
app_details=[] :: list(),
applications=[] :: list(),
included_applications=[] :: [atom()],
@ -177,13 +177,13 @@ new(Parent, AppName, Vsn, Dir, Deps) ->
deps=Deps}}.
-spec app_to_map(t()) -> #{name := atom(),
vsn := string(),
vsn := binary() | string(),
applications := [atom()],
included_applications := [atom()],
dir := file:name(),
out_dir := file:name(),
ebin_dir := file:name(),
link := boolean()}.
link := false}.
app_to_map(#app_info_t{name=Name,
vsn=Vsn,
applications=Applications,
@ -414,18 +414,18 @@ app_details(AppInfo=#app_info_t{}, AppDetails) ->
AppInfo#app_info_t{app_details=AppDetails}.
%% @doc returns the app's parent in the dep tree.
-spec parent(t()) -> root | binary().
-spec parent(t()) -> root | binary() | string().
parent(#app_info_t{parent=Parent}) ->
Parent.
%% @doc sets the app's parent.
-spec parent(t(), binary() | root) -> t().
-spec parent(t(), binary() | root | string()) -> t().
parent(AppInfo=#app_info_t{}, Parent) ->
AppInfo#app_info_t{parent=Parent}.
%% @doc returns the original version of the app (unevaluated if
%% asking for a semver)
-spec original_vsn(t()) -> binary().
-spec original_vsn(t()) -> binary() | string().
original_vsn(#app_info_t{original_vsn=Vsn}) ->
Vsn.
@ -436,7 +436,7 @@ original_vsn(AppInfo=#app_info_t{}, Vsn) ->
AppInfo#app_info_t{original_vsn=Vsn}.
%% @doc returns the version of the app after evaluation
-spec vsn(t()) -> binary().
-spec vsn(t()) -> binary() | string().
vsn(#app_info_t{vsn=Vsn}) ->
Vsn.
@ -505,7 +505,7 @@ fetch_dir(#app_info_t{fetch_dir=FetchDir}) ->
FetchDir.
%% @doc returns the directory to fetch the dep source to
-spec fetch_dir(t(), file:name()) -> file:name().
-spec fetch_dir(t(), file:name()) -> t().
fetch_dir(AppInfo=#app_info_t{}, FetchDir) ->
AppInfo#app_info_t{fetch_dir=FetchDir}.
@ -559,7 +559,7 @@ source(#app_info_t{source=Source}) ->
Source.
%% @doc sets the source specification for the app
-spec source(t(), string() | tuple() | checkout) -> t().
-spec source(t(), string() | tuple() | checkout | undefined) -> t().
source(AppInfo=#app_info_t{}, Source) ->
AppInfo#app_info_t{source=Source}.

+ 6
- 4
src/rebar_app_utils.erl View File

@ -171,7 +171,7 @@ parse_deps(Parent, DepsDir, Deps, State, Locks, Level) ->
%% (if it is a newer thing) or from the locks specified in the lockfile.
-spec parse_dep(Dep, Parent, Dir, State, Locks, Level) -> rebar_app_info:t() when
Dep :: tuple() | atom() | binary(), % TODO: meta to source() | lock()
Parent :: root | binary(),
Parent :: root | binary() | string(),
Dir :: file:filename(),
State :: rebar_state:t(),
Locks :: [tuple()], % TODO: meta to [lock()]
@ -199,7 +199,7 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) ->
%% @doc converts a dependency definition and a location for it on disk
%% into an app info tuple representing it.
-spec parse_dep(Parent, Dep, Dir, IsLock, State) -> rebar_app_info:t() when
Parent :: root | binary(),
Parent :: root | binary() | string(),
Dep :: tuple() | atom() | binary(), % TODO: meta to source() | lock()
Dir :: file:filename(),
IsLock :: boolean(),
@ -244,7 +244,7 @@ parse_dep(_, Dep, _, _, _) ->
%% @doc convert a dependency that has just been fetched into
%% an app info record related to it
-spec dep_to_app(Parent, Dir, Name, Vsn, Source, IsLock, State) -> rebar_app_info:t() when
Parent :: root | binary(),
Parent :: root | binary() | string(),
Dir :: file:filename(),
Name :: binary(),
Vsn :: iodata() | undefined,
@ -315,7 +315,9 @@ expand_deps_sources(Dep, State) ->
%% around version if required.
-spec update_source(rebar_app_info:t(), Source, rebar_state:t()) ->
rebar_app_info:t() when
Source :: rebar_resource_v2:source().
Source :: rebar_resource_v2:source()
| {pkg, PkgName::string(), PkgVsn::unicode:unicode_binary(), Hash::undefined|binary()}
| {pkg, PkgName::string(), PkgVsn::unicode:unicode_binary(), OldHash::undefined|binary(), Hash::undefined|binary()}.
update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
update_source(AppInfo, {pkg, PkgName, PkgVsn, undefined, Hash}, State);
update_source(AppInfo, {pkg, PkgName, PkgVsn, OldHash, Hash}, State) ->

+ 1
- 1
src/rebar_paths.erl View File

@ -1,7 +1,7 @@
-module(rebar_paths).
-include("rebar.hrl").
-type target() :: deps | plugins.
-type target() :: deps | plugins | runtime.
-type targets() :: [target(), ...].
-export_type([target/0, targets/0]).
-export([set_paths/2, unset_paths/2]).

+ 4
- 3
src/rebar_pkg_resource.erl View File

@ -20,7 +20,7 @@
-include("rebar.hrl").
-include_lib("providers/include/providers.hrl").
-type package() :: {pkg, binary(), binary(), binary(), rebar_hex_repos:repo()}.
-type package() :: {pkg, binary(), binary(), binary(), binary(), rebar_hex_repos:repo()}.
%%==============================================================================
%% Public API
@ -43,7 +43,7 @@ init(Type, State) ->
-spec lock(AppInfo, ResourceState) -> Res when
AppInfo :: rebar_app_info:t(),
ResourceState :: rebar_resource_v2:resource_state(),
Res :: {atom(), string(), any(), binary()}.
Res :: {atom(), string(), any(), binary(), binary()}.
lock(AppInfo, _) ->
{pkg, Name, Vsn, OldHash, Hash, _RepoConfig} = rebar_app_info:source(AppInfo),
{pkg, Name, Vsn, OldHash, Hash}.
@ -209,7 +209,8 @@ store_etag_in_cache(Path, ETag) ->
ETag :: binary(),
ETagPath :: file:name(),
UpdateETag :: boolean(),
Res :: ok | {unexpected_hash, integer(), integer()} | {fetch_fail, binary(), binary()}.
Res :: ok | {unexpected_hash, integer(), integer()} | {fetch_fail, binary(), binary()}
| {bad_registry_checksum, integer(), integer()} | {error, _}.
cached_download(TmpDir, CachePath, Pkg={pkg, Name, Vsn, _OldHash, _Hash, RepoConfig}, State, ETag,
ETagPath, UpdateETag) ->
CDN = maybe_default_cdn(State),

+ 2
- 1
src/rebar_resource_v2.erl View File

@ -22,7 +22,8 @@
-include_lib("providers/include/providers.hrl").
-type resource() :: #resource{}.
-type source() :: {type(), location(), ref()} | {type(), location(), ref(), binary()}.
-type source() :: {type(), location(), ref()} | {type(), location(), ref(), binary()}
| {type(), location(), ref(), binary(), binary()}.
-type type() :: atom().
-type location() :: string().
-type ref() :: any().

+ 2
- 2
src/rebar_utils.erl View File

@ -1027,7 +1027,7 @@ is_list_of_strings(List) when is_list(List) ->
%% @end
%%------------------------------------------------------------------------------
-spec ssl_opts(Url) -> Res when
Url :: string(),
Url :: string() | binary(),
Res :: proplists:proplist().
ssl_opts(Url) ->
case get_ssl_config() of
@ -1045,7 +1045,7 @@ ssl_opts(Url) ->
%%------------------------------------------------------------------------------
-spec ssl_opts(Enabled, Url) -> Res when
Enabled :: atom(),
Url :: string(),
Url :: string() | binary(),
Res :: proplists:proplist().
ssl_opts(ssl_verify_enabled, Url) ->
case check_ssl_version() of

Loading…
Cancel
Save