From cb5558a5dcf88803f38b15fa3664bb4446e9e1a2 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sat, 21 Dec 2019 18:27:39 +0300 Subject: [PATCH 1/4] Ignore http_uri:encode/1 deprecation warning Switching to uri_string as the warning suggest would ruin OTP 20 compatibility. --- src/r3_hex_api.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r3_hex_api.erl b/src/r3_hex_api.erl index e6466f24..42818b9b 100644 --- a/src/r3_hex_api.erl +++ b/src/r3_hex_api.erl @@ -28,6 +28,8 @@ put(Config, Path, Body) -> delete(Config, Path) -> request(Config, delete, Path, undefined). +-compile({nowarn_deprecated_function, [http_uri, encode, 1]}). + %% @private encode_query_string(List) -> QueryString = From c134da2196f4cf7e4e5acb46ad1f3c453e48babc Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sat, 21 Dec 2019 18:27:39 +0300 Subject: [PATCH 2/4] Adapt to stricter unused variable check in OTP 23 See [1] for context. 1. https://bugs.erlang.org/browse/ERL-1113 --- src/r3_hex_tarball.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r3_hex_tarball.erl b/src/r3_hex_tarball.erl index fb8c7986..63b61f8b 100644 --- a/src/r3_hex_tarball.erl +++ b/src/r3_hex_tarball.erl @@ -201,7 +201,7 @@ do_unpack(Files, Output) -> finish_unpack({error, _} = Error) -> Error; finish_unpack(#{metadata := Metadata, files := Files, output := Output}) -> - _Version = maps:get("VERSION", Files), + true = maps:is_key("VERSION", Files), Checksum = decode_base16(maps:get("CHECKSUM", Files)), ContentsBinary = maps:get("contents.tar.gz", Files), case unpack_tarball(ContentsBinary, Output) of From bb9f44c728a281f6180d6b52f0d714ca8e9824a1 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sat, 21 Dec 2019 18:27:39 +0300 Subject: [PATCH 3/4] Ignore deprecation warnings for a few more http_uri funs Switching to uri_string as the warning suggest would ruin OTP 20 compatibility. --- src/r3_hex_api.erl | 2 +- src/rebar_git_resource.erl | 5 ++++- src/rebar_utils.erl | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/r3_hex_api.erl b/src/r3_hex_api.erl index 42818b9b..66a08858 100644 --- a/src/r3_hex_api.erl +++ b/src/r3_hex_api.erl @@ -28,7 +28,7 @@ put(Config, Path, Body) -> delete(Config, Path) -> request(Config, delete, Path, undefined). --compile({nowarn_deprecated_function, [http_uri, encode, 1]}). +-compile({nowarn_deprecated_function, [{http_uri, encode, 1}]}). %% @private encode_query_string(List) -> diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index 4e81c054..b2769746 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -100,6 +100,9 @@ compare_url(Dir, Url) -> ?DEBUG("Comparing git url ~p with ~p", [ParsedUrl, ParsedCurrentUrl]), ParsedCurrentUrl =:= ParsedUrl. +-compile({nowarn_deprecated_function, [{http_uri, parse, 2}, + {http_uri, scheme_defaults, 0}]}). + parse_git_url(Url) -> %% Checks for standard scp style git remote case re:run(Url, ?SCP_PATTERN, [{capture, [host, path], list}, unicode]) of @@ -351,7 +354,7 @@ parse_tags(Dir) -> end. git_clone_options() -> - Option = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of + Option = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of false -> "" ; %% env var not set Opt -> %% env var set to empty or others Opt diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 7b267e37..af52f428 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -908,6 +908,9 @@ get_http_vars(Scheme) -> Config = rebar_config:consult_file(GlobalConfigFile), proplists:get_value(Scheme, Config, OS). +-compile({nowarn_deprecated_function, [{http_uri, parse, 1}, + {http_uri, decode, 1}]}). + set_httpc_options() -> set_httpc_options(https_proxy, get_http_vars(https_proxy)), set_httpc_options(proxy, get_http_vars(http_proxy)). From b93bb358194a0aabc1b4c6f2ce80c0df81d79b6a Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sun, 22 Dec 2019 03:00:22 +0300 Subject: [PATCH 4/4] Only suppress deprecation warnings on OTP 23 For OTP 19 and earlier compatibility. --- src/r3_hex_api.erl | 6 +++++- src/rebar_git_resource.erl | 8 ++++++-- src/rebar_utils.erl | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/r3_hex_api.erl b/src/r3_hex_api.erl index 66a08858..a19472f1 100644 --- a/src/r3_hex_api.erl +++ b/src/r3_hex_api.erl @@ -28,7 +28,11 @@ put(Config, Path, Body) -> delete(Config, Path) -> request(Config, delete, Path, undefined). --compile({nowarn_deprecated_function, [{http_uri, encode, 1}]}). +-ifdef (OTP_RELEASE). + -if(?OTP_RELEASE >= 23). + -compile({nowarn_deprecated_function, [{http_uri, encode, 1}]}). + -endif. +-endif. %% @private encode_query_string(List) -> diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index b2769746..45bc0432 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -100,8 +100,12 @@ compare_url(Dir, Url) -> ?DEBUG("Comparing git url ~p with ~p", [ParsedUrl, ParsedCurrentUrl]), ParsedCurrentUrl =:= ParsedUrl. --compile({nowarn_deprecated_function, [{http_uri, parse, 2}, - {http_uri, scheme_defaults, 0}]}). +-ifdef (OTP_RELEASE). + -if(?OTP_RELEASE >= 23). + -compile({nowarn_deprecated_function, [{http_uri, parse, 2}, + {http_uri, scheme_defaults, 0}]}). + -endif. +-endif. parse_git_url(Url) -> %% Checks for standard scp style git remote diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index af52f428..b9a8e64c 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -908,8 +908,12 @@ get_http_vars(Scheme) -> Config = rebar_config:consult_file(GlobalConfigFile), proplists:get_value(Scheme, Config, OS). --compile({nowarn_deprecated_function, [{http_uri, parse, 1}, - {http_uri, decode, 1}]}). +-ifdef (OTP_RELEASE). + -if(?OTP_RELEASE >= 23). + -compile({nowarn_deprecated_function, [{http_uri, parse, 1}, + {http_uri, decode, 1}]}). + -endif. +-endif. set_httpc_options() -> set_httpc_options(https_proxy, get_http_vars(https_proxy)),