Skip to content

Commit

Permalink
Tooling for new developers (2600hz#5485)
Browse files Browse the repository at this point in the history
* add a kazoo document module checker

* check .src diffs against .erl diff

basic check that if .src has changes but .erl doesn't, that's a
paddlin'. No check is made to make sure the change in .src is also in
.erl which would be next-level if needed.

* check loglines for starting capital letters

does the sed to replace them as well as output error messages

* update sed

add some comments for future maintainers

* not so greedy on the replacement

* update non-conforming log lines

* re-enable other checks

* doc updates
  • Loading branch information
jamesaimonetti authored and icehess committed Feb 5, 2019
1 parent b67568a commit 269ad32
Show file tree
Hide file tree
Showing 62 changed files with 324 additions and 150 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ code_checks:
@$(ROOT)/scripts/check-spelling.bash
@$(ROOT)/scripts/kz_diaspora.bash
@$(ROOT)/scripts/edocify.escript
@$(ROOT)/scripts/kzd_module_check.bash
@$(ROOT)/scripts/check-loglines.bash

apis:
@ERL_LIBS=deps/:core/:applications/ $(ROOT)/scripts/generate-schemas.escript
Expand All @@ -275,6 +277,7 @@ docs: docs-validate docs-report docs-setup docs-build
docs-validate:
@$(ROOT)/scripts/check-scripts-readme.bash
@$(ROOT)/scripts/empty_schema_descriptions.bash
@$(ROOT)/scripts/check-ref-docs.bash

docs-report:
@$(ROOT)/scripts/reconcile_docs_to_index.bash
Expand Down
8 changes: 4 additions & 4 deletions applications/acdc/src/acdc_agent_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ call_event(ServerRef, <<"call_event">>, <<"CHANNEL_REPLACED">>, JObj) ->
call_event(ServerRef, <<"call_event">>, <<"CHANNEL_TRANSFEREE">>, JObj) ->
gen_statem:cast(ServerRef, {'channel_unbridged', call_id(JObj)});
call_event(_, _C, _E, _) ->
lager:info("Unhandled combo: ~s/~s", [_C, _E]).
lager:info("unhandled combo: ~s/~s", [_C, _E]).

%%------------------------------------------------------------------------------
%% @doc
%% @end
%%------------------------------------------------------------------------------
-spec maybe_send_execute_complete(pid(), kz_term:ne_binary(), kz_json:object()) -> 'ok'.
maybe_send_execute_complete(ServerRef, <<"bridge">>, JObj) ->
lager:info("Send EXECUTE_COMPLETE,bridge to ~p with ci: ~s, olci: ~s",
lager:info("send EXECUTE_COMPLETE,bridge to ~p with ci: ~s, olci: ~s",
[ServerRef
,call_id(JObj)
,kz_call_event:other_leg_call_id(JObj)
Expand Down Expand Up @@ -721,11 +721,11 @@ ringing('cast', {'member_connect_satisfied', JObj}, #state{agent_listener=AgentL
,connect_failures=Fails
,max_connect_failures=MaxFails
}=State) ->
lager:info("Received connect_satisfied: check if I should hangup: ~p", [JObj]),
lager:info("received connect_satisfied: check if I should hangup: ~p", [JObj]),
CallId = kz_json:get_ne_binary_value([<<"Call">>, <<"Call-ID">>], JObj, []),
case CallId =:= MemberCallId of
true ->
lager:info("Hanging up: someother agent replies"),
lager:info("hanging up: someother agent replies"),
acdc_agent_listener:channel_hungup(AgentListener, MemberCallId),
acdc_stats:call_missed(AccountId, QueueId, AgentId, MemberCallId, <<"LOSE_RACE">>),
acdc_agent_listener:presence_update(AgentListener, ?PRESENCE_GREEN),
Expand Down
10 changes: 5 additions & 5 deletions applications/acdc/src/acdc_agent_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ acct_status(AcctId) ->
case acdc_agents_sup:find_acct_supervisors(AcctId) of
[] -> lager:info("no agents with account id ~s available", [AcctId]);
As ->
lager:info("Agent Statuses in ~s", [AcctId]),
lager:info("agent Statuses in ~s", [AcctId]),
lists:foreach(fun acdc_agent_sup:status/1, As)
end.

Expand All @@ -48,9 +48,9 @@ acct_restart(AcctId) ->
case acdc_agents_sup:find_acct_supervisors(AcctId) of
[] -> lager:info("no agents with account id ~s available", [AcctId]);
As ->
lager:debug("Terminating existing agent processes in ~s", [AcctId]),
lager:debug("terminating existing agent processes in ~s", [AcctId]),
_ = [exit(Sup, 'kill') || Sup <- As],
lager:info("Restarting agents in ~s", [AcctId]),
lager:info("restarting agents in ~s", [AcctId]),
acdc_init:init_acct_agents(AcctId),
'ok'
end.
Expand All @@ -63,9 +63,9 @@ agent_restart(AcctId, AgentId) ->
case acdc_agents_sup:find_agent_supervisor(AcctId, AgentId) of
'undefined' -> lager:info("no agent ~s in account ~s available", [AgentId, AcctId]);
S ->
lager:info("Terminating existing agent process ~p", [S]),
lager:info("terminating existing agent process ~p", [S]),
exit(S, 'kill'),
lager:info("Restarting agent ~s in ~s", [AgentId, AcctId]),
lager:info("restarting agent ~s in ~s", [AgentId, AcctId]),
_ = acdc_agents_sup:new(AcctId, AgentId),
'ok'
end.
8 changes: 4 additions & 4 deletions applications/call_inspector/src/parsers/ci_chunk.erl
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ do_reorder_dialog(RefParser, Chunks) ->
GroupedByCSeq = lists:keysort(1, group_by(fun c_seq_number/1, Chunks)),
lists:flatmap(fun({_CSeq, ByCSeq}) ->
{ByRefParser, Others} = sort_split_uniq(RefParser, ByCSeq),
%% _ = [lager:debug("ByRefParser ~s", [kz_json:encode(to_json(C))]) || C <- ByRefParser],
%% _ = [lager:debug("byRefParser ~s", [kz_json:encode(to_json(C))]) || C <- ByRefParser],
{Done, Rest} = first_pass(ByRefParser, Others),
%% _ = [lager:debug("Done ~s", [kz_json:encode(to_json(C))]) || C <- Done],
%% _ = [lager:debug("done ~s", [kz_json:encode(to_json(C))]) || C <- Done],
{ReallyDone, NewRest} = second_pass(Done, Rest),
%% _ = [lager:debug("ReallyDone ~s", [kz_json:encode(to_json(C))]) || C <- ReallyDone],
%% _ = [lager:debug("NewRest ~s", [kz_json:encode(to_json(C))]) || C <- NewRest],
%% _ = [lager:debug("reallyDone ~s", [kz_json:encode(to_json(C))]) || C <- ReallyDone],
%% _ = [lager:debug("newRest ~s", [kz_json:encode(to_json(C))]) || C <- NewRest],
ReallyDone ++ NewRest
end
,GroupedByCSeq
Expand Down
15 changes: 15 additions & 0 deletions applications/callflow/doc/skel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Skel

### About Skel

#### Schema

Validator for the skel callflow data object



Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------



30 changes: 15 additions & 15 deletions applications/callflow/src/cf_singular_call_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ maybe_hook_call(Call) ->
-spec send_init_hook(kapps_call:call()) -> boolean().
send_init_hook(Call) ->
lager:debug("===CALL STARTED===", []),
lager:debug("Event: init", []),
lager:debug("Call-ID: ~s", [kapps_call:call_id_direct(Call)]),
lager:debug("To: ~s", [knm_converters:normalize(kapps_call:to_user(Call))]),
lager:debug("From: ~s", [knm_converters:normalize(kapps_call:caller_id_number(Call))]),
lager:debug("Inception: ~s", [get_inception(Call)]),
lager:debug("event: init", []),
lager:debug("call-ID: ~s", [kapps_call:call_id_direct(Call)]),
lager:debug("to: ~s", [knm_converters:normalize(kapps_call:to_user(Call))]),
lager:debug("from: ~s", [knm_converters:normalize(kapps_call:caller_id_number(Call))]),
lager:debug("inception: ~s", [get_inception(Call)]),
lager:debug("================", []),

JObj = kz_json:from_list(
Expand All @@ -108,7 +108,7 @@ send_init_hook(Call) ->
)
of
{'error', Reason} ->
lager:warning("Error when sending singular call init hook: ~p", [Reason]),
lager:warning("error when sending singular call init hook: ~p", [Reason]),
'false';
_ ->
'true'
Expand All @@ -123,14 +123,14 @@ send_init_hook(Call) ->
-spec send_end_hook(kapps_call:call(), kz_json:object()) -> boolean().
send_end_hook(Call, Event) ->
lager:debug("===CALL ENDED===", []),
lager:debug("Event: end", []),
lager:debug("Call-ID: ~s", [kapps_call:call_id_direct(Call)]),
lager:debug("To: ~s", [knm_converters:normalize(kapps_call:to_user(Call))]),
lager:debug("From: ~s", [knm_converters:normalize(kapps_call:caller_id_number(Call))]),
lager:debug("Inception: ~s", [get_inception(Call)]),
lager:debug("CallDuration: ~s", [kz_json:get_value(<<"Duration-Seconds">>, Event)]),
lager:debug("HangupReason: ~s", [kz_json:get_value(<<"Hangup-Cause">>, Event)]),
lager:debug("Disposition: ~s", [kz_json:get_value(<<"Disposition">>, Event)]),
lager:debug("event: end", []),
lager:debug("call-ID: ~s", [kapps_call:call_id_direct(Call)]),
lager:debug("to: ~s", [knm_converters:normalize(kapps_call:to_user(Call))]),
lager:debug("from: ~s", [knm_converters:normalize(kapps_call:caller_id_number(Call))]),
lager:debug("inception: ~s", [get_inception(Call)]),
lager:debug("callDuration: ~s", [kz_json:get_value(<<"Duration-Seconds">>, Event)]),
lager:debug("hangupReason: ~s", [kz_json:get_value(<<"Hangup-Cause">>, Event)]),
lager:debug("disposition: ~s", [kz_json:get_value(<<"Disposition">>, Event)]),
lager:debug("================", []),

ReferredBy = kapps_call:custom_channel_var(<<"Referred-By">>, Call),
Expand Down Expand Up @@ -161,7 +161,7 @@ send_end_hook(Call, Event) ->
)
of
{'error', Reason} ->
lager:warning("Error when sending singular end of call hook: ~p", [Reason]),
lager:warning("error when sending singular end of call hook: ~p", [Reason]),
'false';
_ ->
'true'
Expand Down
12 changes: 6 additions & 6 deletions applications/callflow/src/module/cf_camping_feature.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ nothing() ->

init([Data, Call]) ->
kapps_call_command:answer(Call),
lager:info("Camping feature started"),
lager:info("camping feature started"),
Number = kapps_call:kvs_fetch('cf_capture_group', Call),
CF = cf_flow:lookup(Number, kapps_call:account_id(Call)),
case CF of
Expand All @@ -82,7 +82,7 @@ init([Data, Call]) ->

-spec get_target(state()) -> maybe_m(state()).
get_target(#state{callflow = Callflow} = S) ->
lager:debug("Getting target"),
lager:debug("getting target"),
TargetId = kz_json:get_ne_value([<<"flow">>, <<"data">>, <<"id">>], Callflow),
TargetType = kz_json:get_ne_value([<<"flow">>, <<"module">>], Callflow),
case {TargetType, TargetId} of
Expand All @@ -94,7 +94,7 @@ get_target(#state{callflow = Callflow} = S) ->

-spec check_target_type(state()) -> maybe_m(state()).
check_target_type(#state{type = TargetType} = S) ->
lager:debug("Checking target type"),
lager:debug("checking target type"),
case lists:member(TargetType, [<<"offnet">>, <<"user">>, <<"device">>]) of
'true' -> just(S);
'false' -> nothing()
Expand All @@ -115,7 +115,7 @@ get_channels(#state{type = TargetType, id = TargetId} = S, Call) ->

-spec check_self(state(), kapps_call:call()) -> maybe_m(state()).
check_self(State, Call) ->
lager:debug("Check on self"),
lager:debug("check on self"),
case {kapps_call:authorizing_id(Call), kapps_call:authorizing_type(Call)} of
{'undefined', _} -> nothing();
{_, 'undefined'} -> nothing();
Expand All @@ -124,7 +124,7 @@ check_self(State, Call) ->

-spec send_request(state(), kapps_call:call()) -> maybe_m('ok').
send_request(#state{channels = Channels} = S, Call) ->
lager:debug("Sending request"),
lager:debug("sending request"),
case Channels of
[] -> no_channels(S, Call);
_ -> has_channels(S, Call)
Expand Down Expand Up @@ -166,7 +166,7 @@ get_sip_usernames_for_target(TargetId, TargetType, Call) ->
<<"user">> -> kz_attributes:owned_by(TargetId, <<"device">>, Call);
<<"device">> -> [TargetId];
_Else ->
lager:debug("Can't found camping target's type. May be wrong extension number?"),
lager:debug("can't found camping target's type. May be wrong extension number?"),
[]
end,
AccountDb = kapps_call:account_db(Call),
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_check_cid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ handle_no_match(Call) ->
%%------------------------------------------------------------------------------
-spec is_callflow_child(kz_term:ne_binary(), kapps_call:call()) -> boolean().
is_callflow_child(Name, Call) ->
lager:debug("Looking for callflow child ~s", [Name]),
lager:debug("looking for callflow child ~s", [Name]),
case cf_exe:attempt(Name, Call) of
{'attempt_resp', 'ok'} ->
lager:debug("found callflow child"),
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_cidlistmatch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ handle_no_match(Call) ->
%%------------------------------------------------------------------------------
-spec is_callflow_child(kz_term:ne_binary(), kapps_call:call()) -> boolean().
is_callflow_child(Name, Call) ->
lager:debug("Looking for callflow child ~s", [Name]),
lager:debug("looking for callflow child ~s", [Name]),
case cf_exe:attempt(Name, Call) of
{'attempt_resp', 'ok'} ->
lager:debug("found callflow child"),
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_dynamic_cid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ maybe_route_to_callflow(Data, Call, Number, <<"lists">>) ->
maybe_restrict_call(Data, Call, Number, Flow) ->
case should_restrict_call(Data, Call, Number) of
'true' ->
lager:info("Not allowed to call this destination, terminate", []),
lager:info("not allowed to call this destination, terminate", []),
_ = kapps_call_command:answer(Call),
_ = kapps_call_command:prompt(<<"cf-unauthorized_call">>, Call),
_ = kapps_call_command:queued_hangup(Call),
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_intercept.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ is_owner_same_group(Call, DeviceId, OwnerId, GroupId) ->
,kz_json:get_json_value(<<"endpoints">>, GroupJObj, kz_json:new())
);
{'error', _E} ->
lager:debug("Error while opening group ~s: ~p", [GroupId, _E]),
lager:debug("error while opening group ~s: ~p", [GroupId, _E]),
'false'
end.

Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_intercept_feature.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ handle(Data, Call) ->
{'ok', Params} ->
maybe_intercept(Data, Call, Params);
{'error', _E} ->
lager:info("Error <<~s>> processing intercept '~s' for number ~s"
lager:info("error <<~s>> processing intercept '~s' for number ~s"
,[_E, InterceptType, Number]
),
_ = kapps_call_command:b_play(<<"park-no_caller">>, Call),
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_notification.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ handle(Data, Call) ->
case kz_json:get_ne_binary_value(<<"send_at">>, Data, <<"channel_destroy">>) of
<<"channel_destroy">> -> add_handler(Data, Call);
<<"callflow_exec">> -> send_notification(Call, [], Data);
Value -> lager:warning("Bad value of \"send_at\": \"~s\"", [Value])
Value -> lager:warning("bad value of \"send_at\": \"~s\"", [Value])
end,
cf_exe:continue(Call).

Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ use_endpoint_prefs(Call) ->

-spec check_inception(kapps_call:call()) -> kz_term:proplist().
check_inception(Call) ->
lager:debug("Checking inception of call"),
lager:debug("checking inception of call"),
case kapps_call:inception(Call) of
'undefined' -> get_privacy_prefs_from_endpoint(Call);
_Else -> []
Expand Down
6 changes: 3 additions & 3 deletions applications/callflow/src/module/cf_voicemail.erl
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ setup_mailbox(#mailbox{media_extension=Ext}=Box, Call) ->
{'ok', _} = kapps_call_command:b_prompt(<<"vm-setup_complete">>, Call),
Box1#mailbox{is_setup='true'};
{'error', 'max_retry'} ->
lager:debug("Hanging up channel after several empty or invalid pins"),
lager:debug("hanging up channel after several empty or invalid pins"),
_ = kapps_call_command:b_prompt(<<"vm-goodbye">>, Call),
{'error', 'channel_hungup'}
end.
Expand Down Expand Up @@ -1282,7 +1282,7 @@ record_unavailable_greeting(AttachmentName, #mailbox{unavailable_media_id=MediaI
check_media_source(AttachmentName, Box, Call, JObj) ->
case kz_json:get_ne_binary_value(<<"media_source">>, JObj) of
<<"upload">> ->
lager:debug("The voicemail greeting media is a web upload, let's not touch it,"
lager:debug("the voicemail greeting media is a web upload, let's not touch it,"
++ " it may be in use in some other mailbox. We create new media document."
),
record_unavailable_greeting(AttachmentName, Box#mailbox{unavailable_media_id='undefined'}, Call);
Expand Down Expand Up @@ -1454,7 +1454,7 @@ change_pin(#mailbox{mailbox_id=Id
mailbox() |
{'error', any()}.
invalid_pin(_Box, _Call, Loop) when Loop >= ?MAX_INVALID_PIN_LOOPS ->
lager:debug("Several empty or invalid pins"),
lager:debug("several empty or invalid pins"),
{'error', 'max_retry'};
invalid_pin(Box, Call, Loop) ->
case kapps_call_command:b_prompt(<<"vm-pin_invalid">>, Call) of
Expand Down
12 changes: 6 additions & 6 deletions applications/camper/src/camper_offnet_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ start_link(Args) ->
init([JObj]) ->
Exten = kz_json:get_value(<<"Number">>, JObj),
Call = kapps_call:from_json(kz_json:get_value(<<"Call">>, JObj)),
lager:info("Started offnet handler(~p) for request ~s->~s", [self(), kapps_call:from_user(Call), Exten]),
lager:info("started offnet handler(~p) for request ~s->~s", [self(), kapps_call:from_user(Call), Exten]),

MaxTriesSystem = kapps_config:get_integer(?CAMPER_CONFIG_CAT, <<"tries">>, 10),
MaxTries = kz_json:get_integer_value(<<"Tries">>, JObj, MaxTriesSystem),
Expand Down Expand Up @@ -172,7 +172,7 @@ handle_cast({'parked', <<_/binary>> = CallId}, #state{moh=MOH
],
kapi_dialplan:publish_command(CtrlQ, props:filter_undefined(Hold)),
Req = build_bridge_request(CallId, Call, Queue),
lager:debug("Publishing bridge request"),
lager:debug("publishing bridge request"),
kapi_resource:publish_originate_req(Req),
{'noreply', State#state{parked_call = CallId}};
handle_cast('wait', #state{try_after = Time} = State) ->
Expand Down Expand Up @@ -225,21 +225,21 @@ handle_resource_response(JObj, Props) ->
lager:debug("time to bridge"),
gen_listener:cast(Srv, {'parked', CallId});
{<<"call_event">>,<<"CHANNEL_DESTROY">>} ->
lager:debug("Got channel destroy, retrying..."),
lager:debug("got channel destroy, retrying..."),
gen_listener:cast(Srv, 'wait');
{<<"resource">>,<<"originate_resp">>} ->
case {kz_json:get_value(<<"Application-Name">>, JObj)
,kz_json:get_value(<<"Application-Response">>, JObj)
}
of
{<<"bridge">>, <<"SUCCESS">>} ->
lager:debug("Users bridged"),
lager:debug("users bridged"),
gen_listener:cast(Srv, 'stop_campering');
_Ev -> lager:info("Unhandled event: ~p", [_Ev])
_Ev -> lager:info("unhandled event: ~p", [_Ev])
end;
{<<"error">>,<<"originate_resp">>} ->
gen_listener:cast(Srv, 'hangup_parked_call');
_Ev -> lager:info("Unhandled event ~p", [_Ev])
_Ev -> lager:info("unhandled event ~p", [_Ev])
end.

%%------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 269ad32

Please sign in to comment.