From 89c304132b062d64777ce5d20c75a5961e088074 Mon Sep 17 00:00:00 2001 From: Dinis Rosario Date: Wed, 31 Jul 2024 14:21:52 +0100 Subject: [PATCH 1/5] Add project plugins to include hank, lint and depup --- rebar.config | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rebar.config b/rebar.config index 13ac5c7..7ce29ee 100644 --- a/rebar.config +++ b/rebar.config @@ -28,6 +28,13 @@ {base64url, "1.0.1"} ]}. +%% == Plugins == +{project_plugins, [ + {rebar3_hank, "1.4.1"}, + {rebar3_lint, "3.2.6"}, + {rebar3_depup, "0.4.0"} +]}. + %% == Profiles == {profiles, [ From dabc330d95e339e389516f11738668ab232f5061 Mon Sep 17 00:00:00 2001 From: Dinis Rosario Date: Wed, 31 Jul 2024 14:22:09 +0100 Subject: [PATCH 2/5] Ignore ct SUITE for hank --- rebar.config | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rebar.config b/rebar.config index 7ce29ee..e300754 100644 --- a/rebar.config +++ b/rebar.config @@ -121,3 +121,10 @@ locals_not_used, deprecated_function_calls ]}. + +%% == Hank == +{hank, [ + {ignore, [ + "test/*_SUITE.erl" + ]} +]}. From c5c85f646d34c2f19175f080f00573ad3a20301d Mon Sep 17 00:00:00 2001 From: Dinis Rosario Date: Wed, 31 Jul 2024 14:36:22 +0100 Subject: [PATCH 3/5] Silence elvis --- elvis.config | 14 +++++++++----- src/apns.erl | 8 +++++--- src/apns_connection.erl | 11 +++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/elvis.config b/elvis.config index d122bc6..eda23b5 100644 --- a/elvis.config +++ b/elvis.config @@ -7,14 +7,18 @@ filter => "*.erl", ruleset => erl_files, rules => [ - {elvis_style, line_length, #{limit => 100}} + {elvis_text_style, line_length, #{limit => 100}} , {elvis_style, god_modules, #{limit => 25, ignore => [apns_connection]}} + , {elvis_style, no_author, disable} + , {elvis_style, no_space, disable} + , {elvis_style, no_if_expression, #{ignore => [apns_connection]}} + , {elvis_style, dont_repeat_yourself, #{min_complexity => 20}} + , {elvis_style, export_used_types, #{ignore => [apns_meta_SUITE, + apns_os_SUITE, + connection_SUITE, + feedback_SUITE]}} ] }, - #{dirs => ["."], - filter => "Makefile", - ruleset => makefiles - }, #{dirs => ["."], filter => "rebar.config", ruleset => rebar_config diff --git a/src/apns.erl b/src/apns.erl index 36b3366..86dd0cb 100644 --- a/src/apns.erl +++ b/src/apns.erl @@ -59,7 +59,6 @@ , apns_push_type => binary() , apns_auth_token => binary() }. --type feedback() :: apns_feedback:feedback(). %%%=================================================================== %%% API @@ -185,7 +184,7 @@ default_headers() -> default_headers(Headers, #{apns_push_type => <<"alert">>}). %% Requests for feedback to APNs. This requires Provider Certificate. --spec get_feedback() -> [feedback()] | {error, term()} | timeout. +-spec get_feedback() -> [apns_feedback:feedback()] | {error, term()} | timeout. get_feedback() -> {ok, Host} = application:get_env(apns, feedback_host), {ok, Port} = application:get_env(apns, feedback_port), @@ -201,7 +200,10 @@ get_feedback() -> get_feedback(Config). %% Requests for feedback to APNs. This requires Provider Certificate. --spec get_feedback(apns_feedback:feedback_config()) -> [feedback()] | {error, term()} | timeout. +-spec get_feedback(apns_feedback:feedback_config()) + -> [apns_feedback:feedback()] + | {error, term()} + | timeout. get_feedback(Config) -> apns_feedback:get_feedback(Config). diff --git a/src/apns_connection.erl b/src/apns_connection.erl index 476bda4..de70bae 100644 --- a/src/apns_connection.erl +++ b/src/apns_connection.erl @@ -100,7 +100,7 @@ , body := binary() }. --type state() :: #{ connection := connection() +-opaque state() :: #{ connection := connection() , gun_pid => pid() , gun_streams => #{gun:stream_ref() => stream_data()} , max_gun_streams := non_neg_integer() @@ -111,6 +111,9 @@ , backoff_ceiling := non_neg_integer() }. +-export_type([keydata/0, + state/0]). + %%%=================================================================== %%% API %%%=================================================================== @@ -622,9 +625,9 @@ get_headers(Headers) -> , {<<"authorization">>, apns_auth_token} ], F = fun({ActualHeader, Key}) -> - case (catch maps:get(Key, Headers)) of - {'EXIT', {{badkey, Key}, _}} -> []; - Value -> [{ActualHeader, Value}] + case maps:find(Key, Headers) of + error -> []; + {ok, Value} -> [{ActualHeader, Value}] end end, lists:flatmap(F, List). From 1a0a86fd923ab08a2b6162d3edc9540ae4db6d2e Mon Sep 17 00:00:00 2001 From: Dinis Rosario Date: Wed, 31 Jul 2024 14:36:43 +0100 Subject: [PATCH 4/5] Add hank and lint into CI jobs --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e728bdb..fc9739d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,4 +23,6 @@ jobs: rebar3-version: '3.22.1' - run: rebar3 as test xref - run: rebar3 as test dialyzer + - run: rebar3 hank + - run: rebar3 lint # - run: rebar3 as test ct From f10c131ec0b8d593c3301983fa00e756b275bcaf Mon Sep 17 00:00:00 2001 From: Dinis Rosario Date: Wed, 31 Jul 2024 14:45:23 +0100 Subject: [PATCH 5/5] Run CI with Erlang OTP 27 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc9739d..efed5ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{matrix.os}} strategy: matrix: - otp_vsn: [24, 25, 26] + otp_vsn: [24, 25, 26, 27] os: [ubuntu-latest] steps: - uses: actions/checkout@v2