Skip to content

Commit

Permalink
dialyzer cleanup (2600hz#5476)
Browse files Browse the repository at this point in the history
filter out localtime because it's bad
  • Loading branch information
jamesaimonetti committed Feb 1, 2019
1 parent 58a5c9e commit 78b4b66
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion applications/crossbar/src/crossbar_init.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ start_link() ->
Dispatch = cowboy_router:compile(crossbar_routes()),

DefaultIP = kz_network_utils:default_binding_ip(),
IP = kapps_config:get_string(?CONFIG_CAT, <<"ip">>, DefaultIP),
IP = kapps_config:get_ne_binary(?CONFIG_CAT, <<"ip">>, DefaultIP),
IPAddress = kz_network_utils:get_supported_binding_ip(IP, DefaultIP),

maybe_start_plaintext(Dispatch, IPAddress),
Expand Down
3 changes: 2 additions & 1 deletion applications/crossbar/src/crossbar_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,8 @@ update_schemas() ->
db_init_schemas() ->
kz_datamgr:suppress_change_notice(),
update_schemas(),
kz_datamgr:enable_change_notice().
kz_datamgr:enable_change_notice(),
'ok'.

%%------------------------------------------------------------------------------
%% @doc Updating system schemas.
Expand Down
18 changes: 9 additions & 9 deletions core/kazoo_apps/src/kapps_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1215,21 +1215,22 @@ log_system_config_errors(Config, ErrorsObj) ->
lists:foreach(fun(J) -> kz_json:foreach(Fun, J) end, ErrorsObj),
'ok'.

-spec validate_system_configs() -> [{kz_term:ne_binary(), kz_json:object()}].
-spec validate_system_configs() -> [{kz_term:ne_binary(), kz_json:objects()}].
validate_system_configs() ->
[{Config, Status}
|| Config <- kapps_config_doc:list_configs(),
Status <- [validate_system_config(Config)],
[{ConfigId, Status}
|| ConfigId <- kapps_config_doc:list_configs(),
Status <- [validate_system_config(ConfigId)],
[] =/= Status
].

-spec validate_system_config(kz_term:ne_binary()) -> kz_json_schema:validation_errors().
-spec validate_system_config(kz_term:ne_binary()) -> kz_json:objects().
validate_system_config(Id) ->
Doc = get_config_document(Id),
Schema = kapps_config_util:system_config_document_schema(Id),
case kz_json_schema:validate(Schema, Doc) of
{'ok', _} -> [];
{'error', Errors} -> [JObj || {_, _, JObj} <- kz_json_schema:errors_to_jobj(Errors)]
{'error', Errors} ->
[JObj || {_, _, JObj} <- kz_json_schema:errors_to_jobj(Errors)]
end.

-spec get_config_document(kz_term:ne_binary()) -> kz_json:object().
Expand All @@ -1247,11 +1248,10 @@ cleanup_system_config(Id) ->
NewDoc = lists:foldl(fun kz_json:delete_key/2, Doc, ErrorKeys),
kz_datamgr:save_doc(?KZ_CONFIG_DB, NewDoc).

-spec error_keys(kz_json_schema:validation_errors()) -> kz_json:paths().
-spec error_keys(kz_json:objects()) -> kz_json:paths().
error_keys(Errors) ->
io:format("errors: ~p~n", [Errors]),
[binary:split(ErrorKey, <<".">>)
|| {_Code, _Message, ErrorJObj} <- Errors,
|| ErrorJObj <- Errors,
ErrorKey <- kz_json:get_keys(ErrorJObj)
].

Expand Down
4 changes: 2 additions & 2 deletions core/kazoo_ast/src/kapps_config_usage.erl
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ default_value(?MOD_FUN_ARGS('kz_json', 'new', [])) ->
default_value(?MOD_FUN_ARGS('kz_util', 'rand_hex_binary', [_Arg])) ->
?UNKNOWN_DEFAULT;
default_value(?MOD_FUN_ARGS('kz_privacy', 'anonymous_caller_id_number', _Args)) ->
default_value(kz_privacy:anonymous_caller_id_number());
kz_privacy:anonymous_caller_id_number();
default_value(?MOD_FUN_ARGS('kz_privacy', 'anonymous_caller_id_name', _Args)) ->
default_value(kz_privacy:anonymous_caller_id_name());
kz_privacy:anonymous_caller_id_name();
default_value(?MOD_FUN_ARGS('kz_term', 'to_binary', [Arg])) ->
default_value(Arg);
default_value(?MOD_FUN_ARGS('kz_term', 'to_integer', [Arg])) ->
Expand Down
13 changes: 7 additions & 6 deletions core/kazoo_stdlib/src/kz_network_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ is_cidr(Address) ->
-spec get_supported_binding_ip() -> inet:ip_address().
get_supported_binding_ip() ->
DefaultIP = default_binding_ip(),
{'ok', DefaultIPAddress} = inet:parse_address(DefaultIP),
{'ok', DefaultIPAddress} = inet:parse_address(kz_term:to_list(DefaultIP)),
DefaultIPAddress.

%% @equiv get_supported_binding_ip(IP, default_binding_ip())
-spec get_supported_binding_ip(kz_term:api_string()) -> inet:ip_address().
-spec get_supported_binding_ip(kz_term:text() | 'undefined') -> inet:ip_address().
get_supported_binding_ip('undefined') ->
get_supported_binding_ip();
get_supported_binding_ip(IP) ->
Expand Down Expand Up @@ -167,7 +167,8 @@ get_supported_binding_ip(IP) ->
%% @throws {error, Reason::kz_term:ne_binary()}
%% @end
%%------------------------------------------------------------------------------
-spec get_supported_binding_ip(kz_term:api_string(), kz_term:api_string()) -> inet:ip_address().
-spec get_supported_binding_ip(kz_term:text() | 'undefined', kz_term:text() | 'undefined') ->
inet:ip_address().
get_supported_binding_ip('undefined', 'undefined') ->
get_supported_binding_ip();
get_supported_binding_ip('undefined', DefaultIP) ->
Expand Down Expand Up @@ -227,13 +228,13 @@ detect_ip_family(IP) ->
%% @throws {error, Reason::kz_term:ne_binary()}
%% @end
%%------------------------------------------------------------------------------
-spec default_binding_ip() -> string().
-spec default_binding_ip() -> kz_term:ne_binary().
default_binding_ip() ->
default_binding_ip(is_protocol_family_supported('inet')
,is_protocol_family_supported('inet6')
).

-spec default_binding_ip(boolean(), boolean()) -> string().
-spec default_binding_ip(boolean(), boolean()) -> kz_term:ne_binary().
default_binding_ip('true', _) -> ?BIND_ALL_INTERFACE_4;
default_binding_ip('false', 'true') -> ?BIND_ALL_INTERFACE_6;
default_binding_ip('false', 'false') ->
Expand All @@ -256,7 +257,7 @@ is_protocol_family_supported(Family) ->
%% @see get_supported_binding_ip/2
%% @end
%%------------------------------------------------------------------------------
-spec detect_ip_is_bindable('inet' | 'inet6' | kz_term:ne_binary() | string() | {'inet' | 'inet6', inet:ip_address()} | {'error', 'einval'}) ->
-spec detect_ip_is_bindable('inet' | 'inet6' | kz_term:text() | {'inet' | 'inet6', inet:ip_address()} | {'error', 'einval'}) ->
{'ok', 'inet' | 'inet6', inet:ip_address()} |
{'error', 'inet' | 'inet6'| 'einval', string()}.
detect_ip_is_bindable(IP) when is_binary(IP) ->
Expand Down
4 changes: 3 additions & 1 deletion scripts/check-dialyzer.escript
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ warn(PLT, Options, Paths) ->
find_unknown_modules(_PLT, BeamPaths, 'false') -> BeamPaths;
find_unknown_modules(PLT, BeamPaths, 'true') ->
UnknownModules = [M ||
{'warn_unknown', _, {'unknown_function',{M, _F, _Arity}}} <- do_scan_unknown(PLT, BeamPaths)
{'warn_unknown', _, {'unknown_function',{M, _F, _Arity}}} <- do_scan_unknown(PLT, BeamPaths),
M =/= 'localtime' % excluded cause raw dict makes dialyzer sad
],

[fix_path(MPath) ||
M <- lists:usort(UnknownModules),
MPath <- [code:which(M)],
Expand Down

0 comments on commit 78b4b66

Please sign in to comment.