Skip to content

Commit

Permalink
[inaka/elvis#402] ct:print added to no_debug_call rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ferigis committed Feb 9, 2017
1 parent 2d20d84 commit 5124902
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ no_debug_call(Config, Target, RuleConfig) ->
{Root, _} = elvis_file:parse_tree(Config, Target),
ModuleName = elvis_code:module_name(Root),
DefaultDebugFuns = [{ct, pal},
{ct, print, 1},
{ct, print, 2},
{ct, print, 3},
{ct, print, 4},
{ct, print, 5},
{io, format, 1},
{io, format, 2}],
DebugFuns = maps:get(debug_functions, RuleConfig, DefaultDebugFuns),
Expand Down
4 changes: 3 additions & 1 deletion test/examples/fail_no_debug_call.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ fail() ->
% Sending explicit io to a device is not considered debugging
io:format(user, "Not a debug print ~s~n", ["Not debug"]),
ct:pal("Debug"),
ct:pal("Debug ~s", ["Debug Info"]).
ct:pal("Debug ~s", ["Debug Info"]),
ct:print("Debug"),
ct:print("Debug ~s", ["Debug Info"]).
7 changes: 5 additions & 2 deletions test/style_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ verify_no_debug_call(_Config) ->
PathFail = "fail_no_debug_call.erl",
{ok, FileFail} = elvis_test_utils:find_file(SrcDirs, PathFail),

[_, _, _, _] = elvis_style:no_debug_call(ElvisConfig, FileFail, #{}),
[_, _, _, _, _, _] = elvis_style:no_debug_call(ElvisConfig, FileFail, #{}),

RuleConfig = #{ignore => [fail_no_debug_call]},
[] = elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig),
Expand All @@ -538,7 +538,10 @@ verify_no_debug_call(_Config) ->

RuleConfig4 = #{debug_functions => [{io, format}]},
[_, _, _] =
elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig4).
elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig4),

RuleConfig5 = #{debug_functions => [{ct, print}]},
[_, _] = elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig5).

-spec verify_no_nested_try_catch(config()) -> any().
verify_no_nested_try_catch(_Config) ->
Expand Down

0 comments on commit 5124902

Please sign in to comment.