Skip to content

Commit

Permalink
Apply stronger dialyzer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Sep 5, 2024
1 parent 53c7348 commit 79f7d01
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ for the `OperationID` operation.
OperationID :: operation_id(),
Code :: 200..599,
Body :: jesse:json_term(),
ValidatorState :: jesse_state:state()) -> ok | no_return().
ValidatorState :: jesse_state:state()) ->
ok | {ok, term()} | [ok | {ok, term()}] | no_return().
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#responses}}validate_response('{{operationId}}', {{code}}, Body, ValidatorState) ->
validate_response_body('{{dataType}}', '{{baseType}}', Body, ValidatorState);
{{/responses}}
Expand Down Expand Up @@ -393,7 +394,7 @@ to_list(V) when is_atom(V) -> atom_to_list(V);
to_list(V) when is_integer(V) -> integer_to_list(V);
to_list(V) when is_float(V) -> float_to_list(V).

-spec to_float(iodata()) -> number().
-spec to_float(iodata()) -> float().
to_float(V) ->
binary_to_float(iolist_to_binary([V])).

Expand Down Expand Up @@ -438,7 +439,7 @@ get_openapi_path() ->

-include_lib("kernel/include/file.hrl").

-spec priv_dir(Application :: atom()) -> file:filename().
-spec priv_dir(Application :: atom()) -> file:name_all().
priv_dir(AppName) ->
case code:priv_dir(AppName) of
Value when is_list(Value) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
{jesse, "1.8.1"}
]}.

{dialyzer, [{plt_extra_apps, [cowboy, cowlib, ranch, jesse]}]}.
{dialyzer,
[{plt_extra_apps, [cowboy, cowlib, ranch, jesse]},
{warnings, [missing_return, unknown]}
]}.

{xref_checks,
[undefined_function_calls, deprecated_function_calls, deprecated_functions]}.
5 changes: 4 additions & 1 deletion samples/server/echo_api/erlang-server/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
{jesse, "1.8.1"}
]}.

{dialyzer, [{plt_extra_apps, [cowboy, cowlib, ranch, jesse]}]}.
{dialyzer,
[{plt_extra_apps, [cowboy, cowlib, ranch, jesse]},
{warnings, [ missing_return, unknown]}
]}.

{xref_checks,
[undefined_function_calls, deprecated_function_calls, deprecated_functions]}.
7 changes: 4 additions & 3 deletions samples/server/echo_api/erlang-server/src/openapi_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ for the `OperationID` operation.
OperationID :: operation_id(),
Code :: 200..599,
Body :: jesse:json_term(),
ValidatorState :: jesse_state:state()) -> ok | no_return().
ValidatorState :: jesse_state:state()) ->
ok | {ok, term()} | [ok | {ok, term()}] | no_return().
validate_response('TestAuthHttpBasic', 200, Body, ValidatorState) ->
validate_response_body('binary', 'string', Body, ValidatorState);
validate_response('TestAuthHttpBearer', 200, Body, ValidatorState) ->
Expand Down Expand Up @@ -872,7 +873,7 @@ to_list(V) when is_atom(V) -> atom_to_list(V);
to_list(V) when is_integer(V) -> integer_to_list(V);
to_list(V) when is_float(V) -> float_to_list(V).

-spec to_float(iodata()) -> number().
-spec to_float(iodata()) -> float().
to_float(V) ->
binary_to_float(iolist_to_binary([V])).

Expand Down Expand Up @@ -917,7 +918,7 @@ get_openapi_path() ->

-include_lib("kernel/include/file.hrl").

-spec priv_dir(Application :: atom()) -> file:filename().
-spec priv_dir(Application :: atom()) -> file:name_all().
priv_dir(AppName) ->
case code:priv_dir(AppName) of
Value when is_list(Value) ->
Expand Down
5 changes: 4 additions & 1 deletion samples/server/petstore/erlang-server/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
{jesse, "1.8.1"}
]}.

{dialyzer, [{plt_extra_apps, [cowboy, cowlib, ranch, jesse]}]}.
{dialyzer,
[{plt_extra_apps, [cowboy, cowlib, ranch, jesse]},
{warnings, [ missing_return, unknown]}
]}.

{xref_checks,
[undefined_function_calls, deprecated_function_calls, deprecated_functions]}.
7 changes: 4 additions & 3 deletions samples/server/petstore/erlang-server/src/openapi_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ for the `OperationID` operation.
OperationID :: operation_id(),
Code :: 200..599,
Body :: jesse:json_term(),
ValidatorState :: jesse_state:state()) -> ok | no_return().
ValidatorState :: jesse_state:state()) ->
ok | {ok, term()} | [ok | {ok, term()}] | no_return().
validate_response('AddPet', 200, Body, ValidatorState) ->
validate_response_body('Pet', 'Pet', Body, ValidatorState);
validate_response('AddPet', 405, Body, ValidatorState) ->
Expand Down Expand Up @@ -719,7 +720,7 @@ to_list(V) when is_atom(V) -> atom_to_list(V);
to_list(V) when is_integer(V) -> integer_to_list(V);
to_list(V) when is_float(V) -> float_to_list(V).

-spec to_float(iodata()) -> number().
-spec to_float(iodata()) -> float().
to_float(V) ->
binary_to_float(iolist_to_binary([V])).

Expand Down Expand Up @@ -764,7 +765,7 @@ get_openapi_path() ->

-include_lib("kernel/include/file.hrl").

-spec priv_dir(Application :: atom()) -> file:filename().
-spec priv_dir(Application :: atom()) -> file:name_all().
priv_dir(AppName) ->
case code:priv_dir(AppName) of
Value when is_list(Value) ->
Expand Down

0 comments on commit 79f7d01

Please sign in to comment.