From 726711ab95341ef090493483a596a561930915be Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 28 Oct 2020 23:42:11 +0000 Subject: [PATCH] Prevent warnings on unused/unhandled code paths --- src/rebar_git_resource.erl | 4 ++-- src/rebar_uri.erl | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index 7a127444..d95fd597 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -124,7 +124,7 @@ parse_git_url(not_scp, Url) -> case rebar_uri:parse(Url, UriOpts) of #{path := Path, host := Host} -> {ok, {Host, filename:rootname(Path, ".git")}}; - {error, Reason} -> + {error, _, Reason} -> {error, Reason} end. @@ -174,7 +174,7 @@ maybe_warn_local_url(Url) -> "Use remote git resources, or a plugin for local dependencies.", case parse_git_url(Url) of {error, no_scheme} -> ?WARN(WarnStr, [Url]); - {error, {no_default_port, _, _}} -> ?WARN(WarnStr, [Url]); + {error, no_default_port} -> ?WARN(WarnStr, [Url]); {error, {malformed_url, _, _}} -> ?WARN(WarnStr, [Url]); _ -> ok end. diff --git a/src/rebar_uri.erl b/src/rebar_uri.erl index a52f0e02..428e4870 100644 --- a/src/rebar_uri.erl +++ b/src/rebar_uri.erl @@ -17,12 +17,13 @@ parse(URIString) -> parse(URIString, URIOpts) -> case uri_string:parse(URIString) of #{path := ""} = Map -> apply_opts(Map#{path => "/"}, URIOpts); - Map -> apply_opts(Map, URIOpts) + Map when is_map(Map) -> apply_opts(Map, URIOpts); + {error, _, _} = E -> E end. -else. -spec parse(URIString) -> URIMap when URIString :: iodata(), - URIMap :: map() | {error, atom(), term()}. + URIMap :: map() | {error, term(), term()}. parse(URIString) -> parse(URIString, []). @@ -33,7 +34,7 @@ parse(URIString, URIOpts) -> %% no additional parser/term info available to us, %% e.g. see what uri_string returns in %% uri_string:parse(<<"h$ttp:::://////lolz">>). - {error, Reason, ""}; + {error, "", Reason}; {ok, {Scheme, UserInfo, Host, Port, Path, Query}} -> #{ scheme => rebar_utils:to_list(Scheme),