Skip to content

Commit c2c1925

Browse files
fenollpicehess
authored andcommitted
Type most records (2600hz#4041)
* Update kz.mk * type-records: type some record fields * type-records: disable option because of included untyped OTP records * type-records: make fmt * type-records: appease Dialyzer * type-records: do not store temporary data and violate record type for no reason * type-records: finish Dialyzing
1 parent b94923a commit c2c1925

25 files changed

+126
-124
lines changed

applications/acdc/src/acdc_stats.hrl

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77

88
-define(MAX_RESULT_SET, kapps_config:get_integer(?CONFIG_CAT, <<"max_result_set">>, 25)).
99

10-
-record(agent_miss, {
11-
agent_id :: api_binary()
10+
-record(agent_miss, {agent_id :: api_binary()
1211
,miss_reason :: api_binary()
1312
,miss_timestamp = kz_time:current_tstamp() :: pos_integer()
14-
}).
13+
}).
1514
-type agent_miss() :: #agent_miss{}.
1615
-type agent_misses() :: [agent_miss()].
1716

18-
-record(call_stat, {
19-
id :: api_binary() | '_' %% call_id::queue_id
17+
-record(call_stat, {id :: api_binary() | '_' %% call_id::queue_id
2018
,call_id :: api_binary() | '_'
2119
,account_id :: api_binary() | '$1' | '_'
2220
,queue_id :: api_binary() | '$2' | '_'
@@ -39,16 +37,15 @@
3937
,caller_id_number :: api_binary() | '_'
4038
,caller_priority :: api_integer() | '_'
4139
,is_archived = 'false' :: boolean() | '$2' | '$3' | '_'
42-
}).
40+
}).
4341
-type call_stat() :: #call_stat{}.
4442

4543

4644
-define(STATUS_STATUSES, [<<"logged_in">>, <<"logged_out">>, <<"ready">>
4745
,<<"connecting">>, <<"connected">>
4846
,<<"wrapup">>, <<"paused">>, <<"outbound">>
4947
]).
50-
-record(status_stat, {
51-
id :: api_binary() | '_'
48+
-record(status_stat, {id :: api_binary() | '_'
5249
,agent_id :: api_binary() | '$2' | '_'
5350
,account_id :: api_binary() | '$1' | '_'
5451
,status :: api_binary() | '$4' | '_'
@@ -60,7 +57,7 @@
6057
,caller_id_name :: api_binary() | '_'
6158
,caller_id_number :: api_binary() | '_'
6259
,is_archived = 'false' :: boolean() | '$1' | '$2' | '_'
63-
}).
60+
}).
6461
-type status_stat() :: #status_stat{}.
6562

6663

applications/call_inspector/src/ci_datastore.erl

+4-6
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
-record(state, {}).
3838
-type state() :: #state{}.
3939

40-
-record(object, {call_id
41-
,timestamp
42-
,type
43-
,value
40+
-record(object, {call_id :: ne_binary()
41+
,timestamp = kz_time:current_tstamp() :: gregorian_seconds()
42+
,type :: chunk | analysis
43+
,value :: ci_chunk:chunk() | ci_analysis:analysis()
4444
}).
4545
-type object() :: #object{}.
4646

@@ -156,7 +156,6 @@ handle_call(_Request, _From, State) ->
156156
-spec handle_cast(any(), state()) -> handle_cast_ret_state(state()).
157157
handle_cast({'store_chunk', CallId, Chunk}, State) ->
158158
Object = #object{call_id=CallId
159-
,timestamp=kz_time:current_tstamp()
160159
,type='chunk'
161160
,value=Chunk
162161
},
@@ -165,7 +164,6 @@ handle_cast({'store_chunk', CallId, Chunk}, State) ->
165164
{'noreply', State};
166165
handle_cast({'store_analysis', CallId, Analysis}, State) ->
167166
Object = #object{call_id=CallId
168-
,timestamp=kz_time:current_tstamp()
169167
,type='analysis'
170168
,value=Analysis
171169
},

applications/callflow/src/module/cf_call_forward.erl

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
-define(CALLFWD_NUMBER_TIMEOUT, kapps_config:get_integer(?MOD_CONFIG_CAT, <<"callfwd_number_timeout">>, 8000)).
2525

2626
-record(keys, {menu_toggle_cf =
27-
kapps_config:get_binary(?MOD_CONFIG_CAT, [<<"keys">>, <<"menu_toggle_option">>], <<"1">>)
27+
kapps_config:get_ne_binary(?MOD_CONFIG_CAT, [<<"keys">>, <<"menu_toggle_option">>], <<"1">>)
28+
:: ne_binary()
2829
,menu_change_number =
29-
kapps_config:get_binary(?MOD_CONFIG_CAT, [<<"keys">>, <<"menu_change_number">>], <<"2">>)
30+
kapps_config:get_ne_binary(?MOD_CONFIG_CAT, [<<"keys">>, <<"menu_change_number">>], <<"2">>)
31+
:: ne_binary()
3032
}).
3133
-type keys() :: #keys{}.
3234

3335
-record(callfwd, {keys = #keys{} :: keys()
34-
,doc_id = 'undefined' :: api_binary()
36+
,doc_id :: api_ne_binary()
3537
,enabled = 'false' :: boolean()
3638
,number = <<>> :: binary()
3739
,require_keypress = 'true' :: boolean()

applications/callflow/src/module/cf_directory.erl

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@
7474
%%------------------------------------------------------------------------------
7575
%% Records
7676
%%------------------------------------------------------------------------------
77-
-record(directory_user, {
78-
first_name :: ne_binary()
77+
-record(directory_user, {first_name :: ne_binary()
7978
,last_name :: ne_binary()
8079
,full_name :: ne_binary()
8180
,first_last_keys :: ne_binary() % DTMF-version of first, last
8281
,last_first_keys :: ne_binary() % DTMF-version of last, first
8382
,callflow_id :: ne_binary() % what callflow to use on match
8483
,name_audio_id :: api_binary() % pre-recorded audio of user's name
85-
}).
84+
}).
8685
-type directory_user() :: #directory_user{}.
8786
-type directory_users() :: [directory_user()].
8887

applications/callflow/src/module/cf_dynamic_cid.erl

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@
2525
-define(MOD_CONFIG_CAT, <<(?CF_CONFIG_CAT)/binary, ".dynamic_cid">>).
2626

2727
-define(REJECT_PROMPT
28-
,kapps_config:get_binary(?MOD_CONFIG_CAT, <<"reject_prompt">>, <<"dynamic-cid-invalid_using_default">>)
28+
,kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"reject_prompt">>, <<"dynamic-cid-invalid_using_default">>)
2929
).
3030

3131
-record(prompts
3232
,{accept_tone =
33-
kapps_config:get_binary(?MOD_CONFIG_CAT, <<"accept_prompt">>, <<"tone_stream://%(250,50,440)">>)
34-
,reject_tone =
35-
kz_media_util:get_prompt(?REJECT_PROMPT)
33+
kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"accept_prompt">>, <<"tone_stream://%(250,50,440)">>)
34+
:: ne_binary()
35+
,reject_tone = kz_media_util:get_prompt(?REJECT_PROMPT) :: api_ne_binary()
3636
,default_prompt =
3737
kz_media_util:get_prompt(
38-
kapps_config:get_binary(?MOD_CONFIG_CAT, <<"default_prompt">>, <<"dynamic-cid-enter_cid">>)
38+
kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"default_prompt">>, <<"dynamic-cid-enter_cid">>)
3939
)
40+
:: ne_binary()
4041
}).
4142
-type prompts() :: #prompts{}.
4243

applications/callflow/src/module/cf_menu.erl

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
%%% Karl Anderson
1212
%%%-------------------------------------------------------------------
1313
-module(cf_menu).
14-
1514
-behaviour(gen_cf_action).
1615

1716
-export([handle/2]).
@@ -20,12 +19,10 @@
2019

2120
-define(MOD_CONFIG_CAT, <<(?CF_CONFIG_CAT)/binary, ".menu">>).
2221

23-
-record(menu_keys, {
24-
%% Record Review
25-
save = <<"1">> :: ne_binary()
22+
-record(menu_keys, {save = <<"1">> :: ne_binary() %% Record Review
2623
,listen = <<"2">> :: ne_binary()
2724
,record = <<"3">> :: ne_binary()
28-
}).
25+
}).
2926
-type menu_keys() :: #menu_keys{}.
3027
-define(MENU_KEY_LENGTH, 1).
3128

applications/callflow/src/module/cf_voicemail.erl

+33-34
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
%%% James Aimonetti
1515
%%%-------------------------------------------------------------------
1616
-module(cf_voicemail).
17-
1817
-behaviour(gen_cf_action).
1918

2019
-include("callflow.hrl").
@@ -95,39 +94,39 @@
9594

9695
-define(DEFAULT_FIND_BOX_PROMPT, <<"vm-enter_id">>).
9796

98-
-record(keys, {operator = <<"0">>
99-
%% Compose Voicemail
100-
,login = <<"*">>
101-
102-
%% Record Review
103-
,save = <<"1">>
104-
,listen = <<"2">>
105-
,record = <<"3">>
106-
107-
%% Main Menu
108-
,hear_new = <<"1">>
109-
,hear_saved = <<"2">>
110-
,configure = <<"5">>
111-
,exit = <<"#">>
112-
113-
%% Config Menu
114-
,rec_unavailable = <<"1">>
115-
,rec_name = <<"2">>
116-
,set_pin = <<"3">>
117-
,rec_temporary_unavailable = <<"4">>
118-
,del_temporary_unavailable = <<"5">>
119-
,return_main = <<"0">>
120-
121-
%% Post playbak
122-
,keep = <<"1">>
123-
,replay = <<"2">>
124-
,forward = <<"3">>
125-
,prev = <<"4">>
126-
,next = <<"6">>
127-
,delete = <<"7">>
128-
129-
%% Greeting or instructions
130-
,continue = 'undefined'
97+
-record(keys, {operator = <<"0">> :: ne_binary()
98+
%% Compose Voicemail
99+
,login = <<"*">> :: ne_binary()
100+
101+
%% Record Review
102+
,save = <<"1">> :: ne_binary()
103+
,listen = <<"2">> :: ne_binary()
104+
,record = <<"3">> :: ne_binary()
105+
106+
%% Main Menu
107+
,hear_new = <<"1">> :: ne_binary()
108+
,hear_saved = <<"2">> :: ne_binary()
109+
,configure = <<"5">> :: ne_binary()
110+
,exit = <<"#">> :: ne_binary()
111+
112+
%% Config Menu
113+
,rec_unavailable = <<"1">> :: ne_binary()
114+
,rec_name = <<"2">> :: ne_binary()
115+
,set_pin = <<"3">> :: ne_binary()
116+
,rec_temporary_unavailable = <<"4">> :: ne_binary()
117+
,del_temporary_unavailable = <<"5">> :: ne_binary()
118+
,return_main = <<"0">> :: ne_binary()
119+
120+
%% Post playbak
121+
,keep = <<"1">> :: ne_binary()
122+
,replay = <<"2">> :: ne_binary()
123+
,forward = <<"3">> :: ne_binary()
124+
,prev = <<"4">> :: ne_binary()
125+
,next = <<"6">> :: ne_binary()
126+
,delete = <<"7">> :: ne_binary()
127+
128+
%% Greeting or instructions
129+
,continue = 'undefined' :: api_ne_binary()
131130
}).
132131
-type vm_keys() :: #keys{}.
133132

applications/crossbar/src/modules/cb_clicktocall.erl

+5-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,11 @@ handle_originate_resp({'timeout', _T}) ->
422422
lager:debug("timed out while originating: ~p", [_T]),
423423
{'error', <<"timed out">>}.
424424

425-
-record(contact, {route, number, name}).
425+
-record(contact, {route :: ne_binary()
426+
,number :: ne_binary()
427+
,name :: ne_binary()
428+
}).
429+
426430
-spec build_originate_req(ne_binary(), cb_context:context()) -> api_terms().
427431
build_originate_req(Contact, Context) ->
428432
AccountId = cb_context:account_id(Context),

applications/crossbar/src/modules/provisioner_contact_list.erl

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
-include("crossbar.hrl").
1616

17-
-record(contact, {id
18-
,callflow
19-
,name
20-
,first_module
21-
,external_numbers = []
22-
,internal_numbers = []
17+
-record(contact, {id :: api_ne_binary()
18+
,callflow :: api_ne_binary()
19+
,name :: api_ne_binary()
20+
,first_module :: api_ne_binary()
21+
,external_numbers = [] :: ne_binaries()
22+
,internal_numbers = [] :: ne_binaries()
2323
}).
2424

2525
-spec build(ne_binary()) -> kz_json:objects().

applications/dth/src/dth_listener.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
-define(BLACKLIST_REFRESH, 60 * ?MILLISECONDS_IN_SECOND).
4040

41-
-record(state, {wsdl_model = 'undefined' :: 'undefined' | #wsdl{}
41+
-record(state, {wsdl_model :: 'undefined' | #wsdl{}
4242
,dth_cdr_url = <<>> :: binary()
4343
}).
4444
-type state() :: #state{}.

applications/ecallmgr/src/ecallmgr_call_control.erl

+2-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@
7777

7878
-type insert_at_options() :: 'now' | 'head' | 'tail' | 'flush'.
7979

80-
-record(state, {
81-
node :: atom()
80+
-record(state, {node :: atom()
8281
,call_id :: ne_binary()
8382
,command_q = queue:new() :: queue:queue()
8483
,current_app :: api_binary()
@@ -96,7 +95,7 @@
9695
,control_q :: api_binary()
9796
,initial_ccvs :: kz_json:object()
9897
,node_down_tref :: api_reference()
99-
}).
98+
}).
10099
-type state() :: #state{}.
101100

102101
-define(RESPONDERS, []).

applications/omnipresence/src/omnipresence.hrl

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
-define(HANGUP_TIME, 10).
2727
-define(OTHER_TIME, 24 * ?SECONDS_IN_HOUR).
2828

29-
-record(omnip_subscription, {
30-
user :: api_binary() | '_' %% [email protected]
29+
-record(omnip_subscription, {user :: api_binary() | '_' %% [email protected]
3130
,from :: api_binary() | <<>> | '_' %% [email protected]
3231
,stalker :: api_binary() | '_' | '$2' % amqp queue to publish updates to
3332
,expires = 0 :: non_neg_integer() | '_' | '$2'
@@ -46,12 +45,12 @@
4645
,last_reply = 0 :: non_neg_integer() | '_'
4746
,last_body :: api_binary() | '_'
4847
,user_agent :: api_binary() | '_'
49-
}).
48+
}).
5049

5150
-type subscription() :: #omnip_subscription{}.
5251
-type subscriptions() :: [subscription()].
5352

54-
-record(channel, {call_id :: api_binary()
53+
-record(channel, {call_id :: api_binary()
5554
,direction :: api_binary()
5655
,state :: api_binary()
5756
,to :: api_binary()

applications/omnipresence/src/omnipresence_listener.erl

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
-define(SERVER, ?MODULE).
2424

25-
-record(state, {subs_pid = 'undefined' :: api_pid()
26-
,subs_ref = 'undefined' :: api_reference()
27-
,queue = 'undefined' :: api_binary()
25+
-record(state, {subs_pid :: api_pid()
26+
,subs_ref :: api_reference()
27+
,queue :: api_binary()
2828
,consuming = 'false' :: boolean()
2929
,sync = 'false' :: boolean()
3030
}).

applications/omnipresence/src/omnipresence_shared_listener.erl

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
-define(SERVER, ?MODULE).
2727

28-
-record(state, {subs_pid = 'undefined' :: api_pid()
29-
,subs_ref = 'undefined' :: api_reference()
28+
-record(state, {subs_pid :: api_pid()
29+
,subs_ref :: api_reference()
3030
}).
3131
-type state() :: #state{}.
3232

core/amqp_cron/src/amqp_cron.erl

+11-7
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@
7575
-type ident() :: name() | pid().
7676
%% The task pid() or name.
7777

78-
-type task() :: {ident(),
79-
amqp_cron_task:schedule(),
80-
amqp_cron_task:execargs()}.
81-
%% Task definition.
82-
83-
-record(state, {tasks = []
84-
,is_leader = 'false'
78+
-type task() :: {name()
79+
,pid()
80+
,amqp_cron_task:schedule()
81+
,amqp_cron_task:execargs()
82+
}.
83+
-type tasks() :: [task()].
84+
85+
-record(state, {tasks = [] :: tasks()
86+
,is_leader = 'false' :: boolean()
8587
}).
8688
-type state() :: #state{}.
8789

@@ -384,6 +386,8 @@ remove_task_if_done(Task, Acc) ->
384386
[Task|Acc]
385387
end.
386388

389+
-spec pid_for_name(binary() | atom(), tasks()) -> pid() |
390+
{error, no_such_name}.
387391
pid_for_name(Name, Tasks) ->
388392
case lists:keyfind(Name, 1, Tasks) of
389393
'false' ->

0 commit comments

Comments
 (0)