Skip to content

Commit

Permalink
elvis 通す
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jun 22, 2024
1 parent 4276f4c commit 353fc0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions elvis.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
{elvis_style, export_used_types, disable},
{elvis_style, private_data_types, disable},
%% 要検討
{elvis_style, no_debug_call, disable},
%% 要検討
{elvis_style, no_throw, disable},
%% 要検討
{elvis_style, no_single_clause_case, disable},
%% 要検討
{elvis_style, max_function_arity, disable},
Expand Down
14 changes: 7 additions & 7 deletions src/jesse_json_path.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ path(Path, P, Default) when is_binary(Path) ->
path(binary:split(Path, <<".">>, [global]), P, Default);
path(Path, P, Default) when is_atom(Path) ->
path(atom_to_binary(Path, utf8), P, Default);
path(Path = [N | _], P, Default) when is_integer(N) ->
path([N | _] = Path, P, Default) when is_integer(N) ->
path(iolist_to_binary(Path), P, Default);
path([], [], Default) ->
Default;
Expand Down Expand Up @@ -108,12 +108,12 @@ to_proplist([]) ->
[];
to_proplist([{}]) ->
[];
to_proplist(L = [{struct, _} | _]) ->
to_proplist([{struct, _} | _] = L) ->
to_proplist_l(L);
to_proplist(L = [{K, _} | _]) when not is_integer(K) ->
to_proplist([{K, _} | _] = L) when not is_integer(K) ->
%% gb_trees is an {integer(), _}
to_proplist_pl(L);
to_proplist(L = [_ | _]) ->
to_proplist([_ | _] = L) ->
first_of(
[fun to_proplist_gb_l/1,
fun to_proplist_pl/1,
Expand Down Expand Up @@ -151,7 +151,7 @@ to_proplist_l(L) ->
[ to_proplist(V) || V <- L ].


to_proplist_pl(L = [{_, _} | _]) ->
to_proplist_pl([{_, _} | _] = L) ->
[ {K, to_proplist(V)} || {K, V} <- L ];
to_proplist_pl([]) ->
[].
Expand Down Expand Up @@ -199,7 +199,7 @@ get_nested_values(<<"@unionOfObjects">>, L, _R) ->
L;
get_nested_values(A, L, R) when is_atom(A) andalso A > '@' andalso A < 'A' ->
get_nested_values(atom_to_binary(A, utf8), L, R);
get_nested_values(K = "@" ++ _, L, R) ->
get_nested_values("@" ++ _ = K, L, R) ->
get_nested_values(iolist_to_binary(K), L, R);
get_nested_values(K, [L | Rest], R) ->
case value(K, L, R) of
Expand All @@ -213,7 +213,7 @@ get_nested_values(_K, [], _R) ->


-spec proplist_type(term()) -> typed_proplist().
proplist_type(P = [{K, _} | _]) ->
proplist_type([{K, _} | _] = P) ->
{P, typeof_elem(K)};
proplist_type({struct, P = [{K, _} | _]}) ->
{P, typeof_elem(K)};
Expand Down
2 changes: 1 addition & 1 deletion src/jesse_state.erl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ new(JsonSchema, Options) ->

%% @doc Removes the last element from `current_path' in `State'.
-spec remove_last_from_path(State :: state()) -> state().
remove_last_from_path(State = #state{current_path = [_Property | Path]}) ->
remove_last_from_path(#state{current_path = [_Property | Path]} = State) ->
State#state{current_path = Path}.


Expand Down
12 changes: 6 additions & 6 deletions src/jesse_validator_draft6.erl
Original file line number Diff line number Diff line change
Expand Up @@ -940,32 +940,32 @@ check_enum(Value, Enum, State) ->
%% @doc format
%% Used for semantic validation.
%% @private
check_format(Value, _Format = <<"date-time">>, State) when is_binary(Value) ->
check_format(Value, <<"date-time">> = _Format, State) when is_binary(Value) ->
case valid_datetime(Value) of
true -> State;
false -> handle_data_invalid(?wrong_format, Value, State)
end;
check_format(Value, _Format = <<"email">>, State) when is_binary(Value) ->
check_format(Value, <<"email">> = _Format, State) when is_binary(Value) ->
case jesse_lib:re_run(Value, <<"^[^@]+@[^@]+$">>) of
match -> State;
nomatch -> handle_data_invalid(?wrong_format, Value, State)
end;
check_format(Value, _Format = <<"hostname">>, State) when is_binary(Value) ->
check_format(Value, <<"hostname">> = _Format, State) when is_binary(Value) ->
%% not yet supported
State;
check_format(Value, _Format = <<"ipv4">>, State) when is_binary(Value) ->
check_format(Value, <<"ipv4">> = _Format, State) when is_binary(Value) ->
%% avoiding inet:parse_ipv4strict_address to maintain R15 compatibility
case inet_parse:ipv4strict_address(binary_to_list(Value)) of
{ok, _IPv4Address} -> State;
{error, einval} -> handle_data_invalid(?wrong_format, Value, State)
end;
check_format(Value, _Format = <<"ipv6">>, State) when is_binary(Value) ->
check_format(Value, <<"ipv6">> = _Format, State) when is_binary(Value) ->
%% avoiding inet:parse_ipv6strict_address to maintain R15 compatibility
case inet_parse:ipv6strict_address(binary_to_list(Value)) of
{ok, _IPv6Address} -> State;
{error, einval} -> handle_data_invalid(?wrong_format, Value, State)
end;
check_format(Value, _Format = <<"uri">>, State) when is_binary(Value) ->
check_format(Value, <<"uri">> = _Format, State) when is_binary(Value) ->
%% not yet supported
State;
check_format(Value, <<"uri-reference">>, State) when is_binary(Value) ->
Expand Down

0 comments on commit 353fc0f

Please sign in to comment.