Skip to content

Commit 8e94eec

Browse files
authored
Merge pull request #120 from paulo-ferraz-oliveira/fix/rebar.config
Tweak `rebar.config` (update deps then fixed issue warnings)
2 parents 7cb195e + 4e9012f commit 8e94eec

9 files changed

+51
-76
lines changed

.github/workflows/main.yml

+3-13
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,9 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
include:
20-
- otp_version: 25
21-
os: ubuntu-22.04
22-
rebar3_version: 3.22
23-
- otp_version: 24
24-
os: ubuntu-22.04
25-
rebar3_version: 3.22
26-
- otp_version: 23
27-
os: ubuntu-20.04
28-
rebar3_version: 3.18
29-
- otp_version: 22
30-
os: ubuntu-20.04
31-
rebar3_version: 3.18
19+
otp_version: [24, 25]
20+
os: [ubuntu-22.04]
21+
rebar3_version: [3.22]
3222

3323
steps:
3424
- uses: actions/checkout@v4

elvis.config

+23-44
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,27 @@
11
[
2-
{
3-
elvis,
4-
[
5-
{config,
6-
[#{dirs => [
7-
"src"
8-
%% TODO: "test"
9-
],
10-
filter => "*.erl",
11-
rules => [
12-
{elvis_style, no_tabs},
13-
{elvis_style, no_trailing_whitespace},
14-
{elvis_style, no_if_expression},
15-
{elvis_style, no_nested_try_catch},
16-
{elvis_style, invalid_dynamic_call,
17-
#{ignore => [
18-
elli,
19-
elli_http,
20-
elli_middleware,
21-
elli_test
22-
]}},
23-
{elvis_style, used_ignored_variable},
24-
{elvis_style, no_behavior_info},
25-
{elvis_style, state_record_and_type},
26-
{elvis_style, no_spec_with_records},
27-
{elvis_style, dont_repeat_yourself},
28-
{elvis_style, no_debug_call}
29-
],
30-
ruleset => erl_files
31-
},
32-
#{dirs => ["."],
33-
filter => "Makefile",
34-
ruleset => makefiles
35-
},
36-
#{dirs => ["."],
37-
filter => "rebar.config",
2+
{elvis, [
3+
{config, [
4+
#{
5+
dirs => ["src/**", "test/**"],
6+
filter => "*.erl",
7+
ruleset => erl_files,
8+
rules => [
9+
{elvis_style, operator_spaces, disable},
10+
{elvis_style, invalid_dynamic_call, disable},
11+
{elvis_style, dont_repeat_yourself, disable},
12+
{elvis_style, no_throw, disable}
13+
]
14+
},
15+
#{
16+
dirs => ["."],
17+
filter => "rebar.config",
3818
ruleset => rebar_config
39-
},
40-
#{dirs => ["."],
41-
filter => "elvis.config",
19+
},
20+
#{
21+
dirs => ["."],
22+
filter => "elvis.config",
4223
ruleset => elvis_config
43-
}
44-
]
45-
}
46-
]
47-
}
24+
}
25+
]}
26+
]}
4827
].

rebar.config

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{erl_first_files, ["src/elli_handler.erl"]}.
22
{erl_opts, [debug_info,
33
{i, "include"}]}.
4-
{minimum_otp_vsn, "22.0"}.
4+
{minimum_otp_vsn, "24"}.
55
{deps, []}.
66
{xref_checks, [undefined_function_calls,locals_not_used]}.
77
{profiles, [
88
{docs, [
9-
{deps, [{edown, "0.8.1"}]},
9+
{deps, [{edown, "0.9.1"}]},
1010
{edoc_opts, [
1111
{preprocess, true},
1212
{def, [
@@ -16,18 +16,18 @@
1616
]}
1717
]},
1818
{test, [
19-
{deps, [{hackney, "1.17.4"}]}
19+
{deps, [{hackney, "1.20.1"}]}
2020
]}
2121
]}.
2222

2323
{shell, [{script_file, "bin/shell.escript"}]}.
2424

2525
{project_plugins, [
26-
{covertool, "2.0.3"}%,
27-
%{rebar3_lint, "v0.1.10"}
26+
{covertool, "2.0.6"},
27+
{rebar3_lint, "3.2.5"}
2828
]}.
2929

30-
%{provider_hooks, [{pre, [{eunit, lint}]}]}.
30+
{provider_hooks, [{pre, [{eunit, lint}]}]}.
3131
{dialyzer, [{plt_extra_apps, [ssl]}]}.
3232

3333
{cover_enabled, true}.

src/elli.erl

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
%% @type req(). A record representing an HTTP request.
3030
-type req() :: #req{}.
31+
-elvis([{elvis_style, private_data_types, disable}]).
3132

3233
%% @type http_method(). An uppercase atom representing a known HTTP verb or a
3334
%% binary for other verbs.
@@ -162,11 +163,7 @@ init([Opts]) ->
162163
| SSLSockOpts]),
163164

164165
Acceptors = ets:new(acceptors, [private, set]),
165-
[begin
166-
Pid = elli_http:start_link(self(), Socket, Options,
167-
{Callback, CallbackArgs}),
168-
ets:insert(Acceptors, {Pid})
169-
end
166+
[http_start(Socket, Options, Callback, CallbackArgs, Acceptors)
170167
|| _ <- lists:seq(1, MinAcceptors)],
171168

172169
{ok, #state{socket = Socket,
@@ -175,6 +172,9 @@ init([Opts]) ->
175172
options = Options,
176173
callback = {Callback, CallbackArgs}}}.
177174

175+
http_start(Socket, Options, Callback, CallbackArgs, Acceptors) ->
176+
Pid = elli_http:start_link(self(), Socket, Options, {Callback, CallbackArgs}),
177+
ets:insert(Acceptors, {Pid}).
178178

179179
%% @hidden
180180
-spec handle_call(get_acceptors, {pid(), _Tag}, state()) ->

src/elli_http.erl

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
-define(CONNECTION_HEADER, <<"connection">>).
3737
-define(TRANSFER_ENCODING_HEADER, <<"Transfer-Encoding">>).
3838

39+
-elvis([{elvis_style, max_function_arity, disable}]).
40+
3941
%% TODO: use this
4042
%% -type connection_token() :: keep_alive | close.
4143

@@ -58,7 +60,7 @@ start_link(Server, ListenSocket, Options, Callback) ->
5860
Options :: proplists:proplist(),
5961
Callback :: elli_handler:callback().
6062
accept(Server, ListenSocket, Options, Callback) ->
61-
case catch elli_tcp:accept(ListenSocket, Server, accept_timeout(Options)) of
63+
case elli_tcp:accept(ListenSocket, Server, accept_timeout(Options)) of
6264
{ok, Socket} ->
6365
t(accepted),
6466
?MODULE:keepalive_loop(Socket, Options, Callback);
@@ -729,7 +731,7 @@ parse_path({abs_path, FullPath}) ->
729731
Query = maps:get(query, URIMap, <<>>),
730732
Port = maps:get(port, URIMap, case Scheme of http -> 80; https -> 443; _ -> undefined end),
731733
{ok, {Scheme, Host, Port}, {Path, split_path(Path), uri_string:dissect_query(Query)}};
732-
parse_path({absoluteURI, Scheme, Host, Port, Path}) ->
734+
parse_path({'absoluteURI', Scheme, Host, Port, Path}) ->
733735
setelement(2, parse_path({abs_path, Path}), {Scheme, Host, Port});
734736
parse_path(_) ->
735737
{error, unsupported_uri}.

src/elli_request.erl

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
| {offset, Offset::non_neg_integer()}
4545
| {suffix, Length::pos_integer()}.
4646

47+
-elvis([{elvis_style, god_modules, disable}]).
4748

4849
%%
4950
%% Helpers for working with a #req{}

src/elli_sendfile.erl

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
-export([sendfile/5]).
77

88
-type sendfile_opts() :: [{chunk_size, non_neg_integer()}].
9+
-export_type([sendfile_opts/0]).
910

1011
%% @doc Send part of a file on a socket.
1112
%%

test/elli_middleware_tests.erl

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ hello_world() ->
2828
?assertMatch(<<"Hello World!">>, body(Response)).
2929

3030
compress() ->
31-
Url = "http://localhost:3002/compressed",
31+
URL = "http://localhost:3002/compressed",
3232
Headers = [{<<"Accept-Encoding">>, <<"gzip">>}],
33-
Response = hackney:get(Url, Headers),
33+
Response = hackney:get(URL, Headers),
3434
?assertHeadersEqual([{<<"Connection">>, <<"Keep-Alive">>},
3535
{<<"Content-Encoding">>, <<"gzip">>},
3636
{<<"Content-Length">>, <<"41">>}],

test/elli_tests.erl

+6-4
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ sendfile_range() ->
472472
?assertMatch(206, status(Response)),
473473
?assertHeadersEqual([{<<"connection">>, <<"Keep-Alive">>},
474474
{<<"content-length">>, <<"400">>},
475-
{<<"Content-Range">>, iolist_to_binary(["bytes 300-699/", integer_to_binary(Size)])}],
475+
{<<"Content-Range">>,
476+
iolist_to_binary(["bytes 300-699/", integer_to_binary(Size)])}],
476477
headers(Response)),
477478
?assertEqual(Expected, body(Response)).
478479

@@ -735,7 +736,8 @@ register_test() ->
735736
ok.
736737

737738
invalid_callback_test() ->
738-
case catch elli:start_link([{callback, elli}]) of
739-
E ->
740-
?assertMatch(invalid_callback, E)
739+
try
740+
elli:start_link([{callback, elli}])
741+
catch _:E ->
742+
?assertMatch(invalid_callback, E)
741743
end.

0 commit comments

Comments
 (0)