Skip to content

Commit d2afcf7

Browse files
committed
lint
1 parent cb4bcb1 commit d2afcf7

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

src/katt.erl

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,20 @@ make_callbacks(Callbacks) ->
138138
-ifdef(OTP_RELEASE). %% OTP 21+
139139
http_uri_parse(URI) ->
140140
case uri_string:parse(URI) of
141-
URIMap when is_map(URIMap) ->
141+
URIMap when is_map(URIMap) ->
142142
Scheme0 = maps:get(scheme, URIMap, <<"no_scheme">>),
143-
Scheme = if is_binary(Scheme0) -> binary_to_atom(Scheme0, utf8); true -> list_to_atom(Scheme0) end,
144-
Host = maps:get(host, URIMap, if is_binary(URI) -> <<>>; true -> "" end),
143+
Scheme = case is_binary(Scheme0) of
144+
true -> binary_to_atom(Scheme0, utf8);
145+
false -> list_to_atom(Scheme0)
146+
end,
147+
DefaultHost = case is_binary(URI) of
148+
true -> <<>>;
149+
false -> ""
150+
end,
151+
Host = maps:get(host, URIMap, DefaultHost),
145152
%% port defaults as per http_uri:scheme_defaults/0
146-
%% see https://github.com/erlang/otp/blob/2831b6c/lib/inets/src/http_lib/http_uri.erl#L101-L107
153+
%% see https://github.com/erlang/otp
154+
%% ... /blob/2831b6c/lib/inets/src/http_lib/http_uri.erl#L101-L107
147155
DefaultPort = case Scheme of
148156
http -> 80;
149157
https -> 443;
@@ -153,14 +161,18 @@ http_uri_parse(URI) ->
153161
tftp -> 69
154162
end,
155163
Port = maps:get(port, URIMap, DefaultPort),
156-
Path = maps:get(path, URIMap, if is_binary(URI) -> <<"/">>; true -> "" end),
164+
DefaultPath = case is_binary(URI) of
165+
true -> <<"/">>;
166+
false -> ""
167+
end,
168+
Path = maps:get(path, URIMap, DefaultPath),
157169
{ ok
158170
, Scheme
159171
, Host
160172
, Port
161173
, Path
162174
};
163-
{error, Reason, _Info} ->
175+
{error, Reason, _Info} ->
164176
{error, Reason}
165177
end.
166178
-else.
@@ -218,7 +230,8 @@ base_url_from_params(ScenarioParams) ->
218230
Protocol = proplists:get_value("protocol", ScenarioParams, ?DEFAULT_PROTOCOL),
219231
Hostname = proplists:get_value("hostname", ScenarioParams, ?DEFAULT_HOSTNAME),
220232
%% port defaults as per http_uri:scheme_defaults/0
221-
%% see https://github.com/erlang/otp/blob/2831b6c/lib/inets/src/http_lib/http_uri.erl#L101-L107
233+
%% see https://github.com/erlang/otp
234+
%% ... /blob/2831b6c/lib/inets/src/http_lib/http_uri.erl#L101-L107
222235
DefaultPort = case Protocol of
223236
"http:" -> 80;
224237
"https:" -> 443;
@@ -290,7 +303,8 @@ run_transactions( From
290303
, Params
291304
, Callbacks
292305
),
293-
ActualResponse = ActualResponse0#katt_response{parsed_body = ActualResponseParsedBody},
306+
ActualResponse =
307+
ActualResponse0#katt_response{parsed_body = ActualResponseParsedBody},
294308
ExpectedResponse = make_katt_response(ActualResponse, Res, Params, Callbacks),
295309
ValidationResult = ValidateFun( ExpectedResponse
296310
, ActualResponse
@@ -419,9 +433,15 @@ get_headers_content_type(HdrsSrc, HdrsTarget0) ->
419433
HdrsTarget = proplists:delete("x-katt-content-type", HdrsTarget0),
420434
HdrsTargetCT = case proplists:is_defined("Content-Type", HdrsTarget) of
421435
true ->
422-
katt_util:merge_proplists(HdrsTarget, [{"Content-Type", ContentType}]);
436+
katt_util:merge_proplists( HdrsTarget
437+
, [{ "Content-Type"
438+
, ContentType
439+
}]);
423440
false ->
424-
katt_util:merge_proplists(HdrsTarget, [{"content-type", ContentType}])
441+
katt_util:merge_proplists( HdrsTarget
442+
, [{ "content-type"
443+
, ContentType
444+
}])
425445
end,
426446
{ContentType, HdrsTarget, HdrsTargetCT}
427447
end.

src/katt_callbacks.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ request(R = #katt_request{}, Params, _Callbacks) ->
175175
Error = {error, _} ->
176176
Error
177177
end.
178-
-dialyzer({no_match, request/3}). % support bare mode for http_request -> katt_util:external_http_request
178+
%% support bare mode for http_request -> katt_util:external_http_request
179+
-dialyzer({no_match, request/3}).
179180

180181
%% @doc Validate a response.
181182
%% @end

0 commit comments

Comments
 (0)