Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #407] Fix bug in max_function_length rule #64

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ rebar
.erlang.mk/
elvis.d
doc
rebar3.crashdump
rebar3.crashdump
.rebar3/
4 changes: 2 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
%% == Dependencies ==

{deps, [ {lager, "3.0.2"}
, {zipper, "1.0.0"}
, {zipper, "1.0.1"}
, {katana_code, "0.1.0"}
]}.

Expand All @@ -85,4 +85,4 @@

%% == Shell ==

{shell, [{apps, [sync]}]}.
{shell, [{apps, [sync]}]}.
13 changes: 12 additions & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{"1.1.0",
[{<<"aleppo">>,{pkg,<<"inaka_aleppo">>,<<"1.0.0">>},1},
{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.7">>},1},
{<<"katana_code">>,{pkg,<<"katana_code">>,<<"0.1.0">>},0},
{<<"lager">>,{pkg,<<"lager">>,<<"3.0.2">>},0},
{<<"zipper">>,{pkg,<<"zipper">>,<<"1.0.0">>},0}].
{<<"zipper">>,
{git,"https://github.com/inaka/zipper.git",
{ref,"47358be662a6749b5b0b932fc0aaad405f537a1c"}},
0}]}.
[
{pkg_hash,[
{<<"aleppo">>, <<"8DB14CF16BB8C263C14FF4C3F69F64D7C849D40888944F4204D2CA74F1114CEB">>},
{<<"goldrush">>, <<"349A351D17C71C2FDAA18A6C2697562ABE136FEC945F147B381F0CF313160228">>},
{<<"katana_code">>, <<"C34F3926A258D6BEACD8D21F140F3D47D175501936431C460B144339D5271A0B">>},
{<<"lager">>, <<"25DC81BC3659B62F5AB9BD073E97DDD894FC4C242019FCCEF96F3889D7366C97">>}]}
].
9 changes: 8 additions & 1 deletion src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,16 @@ no_debug_call(Config, Target, RuleConfig) ->
node_line_limits(FunctionNode) ->
Zipper = elvis_code:code_zipper(FunctionNode),
LineFun = fun(N) -> {L, _} = ktn_code:attr(location, N), L end,
% The first number in `lineNums' list is the location of the first
% line of the function. That's why we use it for the `Min' value.
LineNums = zipper:map(LineFun, Zipper),
% Last function's line
Max = lists:max(LineNums),
Min = lists:min(LineNums),
% If you use `lists:min/1' here, you will get weird results when using
% macros because most of the time macros are defined at the beginning of
% the module, but your function's first line could be in the middle or
% even at the end of the module.
[Min | _] = LineNums, % Min = first function's line
{Min, Max}.

-spec no_nested_try_catch(elvis_config:config(),
Expand Down