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

[#221] fix bug non spacing not detected #223

Merged
merged 2 commits into from
May 11, 2015
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
2 changes: 1 addition & 1 deletion src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ check_operator_spaces_rule(Line, Num, {Position, Operator}, Root) ->
nomatch ->
no_result;
{match, [{Col, _} | _]} ->
Type = case elvis_code:find_by_location(Root, {Num, Col}) of
Type = case elvis_code:find_by_location(Root, {Num, Col + 1}) of
not_found -> undefined;
{ok, Node} -> ktn_code:type(Node)
end,
Expand Down
6 changes: 5 additions & 1 deletion test/examples/fail_operator_spaces.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(fail_operator_spaces).

-export([function1/2,function2/2, function3/2, function4/2]).
-export([function1/2,function2/2, function3/2, function4/2, function5/0]).

%% No space before and after coma,on a comment.

Expand All @@ -20,3 +20,7 @@ function3(Shouldnt, Fail) ->

function4(Should, <<_:10/binary, ",", _/binary>>) ->
Should = [$,, "where $, represents the character ,"].

function5() ->
User = #{name => <<"Juan">>, email => <<"[email protected]">>},
<<"[email protected]">> = maps:get(email,User).
3 changes: 1 addition & 2 deletions test/git_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

-spec all() -> [atom()].
all() ->
Module = ?MODULE,
Exports = Module:module_info(exports),
Exports = ?MODULE:module_info(exports),
[F || {F, _} <- Exports, not lists:member(F, ?EXCLUDED_FUNS)].

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
16 changes: 10 additions & 6 deletions test/style_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@ verify_operator_spaces(_Config) ->
[] = elvis_style:operator_spaces(ElvisConfig, Path, #{}),

RuleConfig = #{rules => [{right, ","}]},
[_, _, _] = elvis_style:operator_spaces(ElvisConfig, Path, RuleConfig),
[_, _, _, _] = elvis_style:operator_spaces(ElvisConfig, Path, RuleConfig),

AppendOptions = #{rules => [{right, "++"}, {left, "++"}]},
[_] = elvis_style:operator_spaces(ElvisConfig, Path, AppendOptions),

AllOptions = #{rules => [{right, ","}, {right, "++"}, {left, "++"}]},
[_, _, _, _] = elvis_style:operator_spaces(ElvisConfig, Path, AllOptions).
[_, _, _, _, _] =
elvis_style:operator_spaces(ElvisConfig, Path, AllOptions).

-spec verify_nesting_level(config()) -> any().
verify_nesting_level(_Config) ->
Expand Down Expand Up @@ -265,9 +266,11 @@ verify_module_naming_convention(_Config) ->
[_] =
elvis_style:module_naming_convention(ElvisConfig, FileFail, RuleConfig),

RuleConfigIgnore = RuleConfig#{ignore => [fail_module_naming_1_convention_1]},
[] =
elvis_style:module_naming_convention(ElvisConfig, FileFail, RuleConfigIgnore).
RuleConfigIgnore =
RuleConfig#{ignore => [fail_module_naming_1_convention_1]},
[] = elvis_style:module_naming_convention(
ElvisConfig, FileFail, RuleConfigIgnore
).


-spec verify_state_record_and_type(config()) -> any().
Expand Down Expand Up @@ -308,7 +311,8 @@ verify_dont_repeat_yourself(_Config) ->
PathFail = "fail_dont_repeat_yourself.erl",
{ok, FileFail} = elvis_test_utils:find_file(SrcDirs, PathFail),
RuleConfig5 = #{min_complexity => 5},
[_, _] = elvis_style:dont_repeat_yourself(ElvisConfig, FileFail, RuleConfig5),
[_, _] =
elvis_style:dont_repeat_yourself(ElvisConfig, FileFail, RuleConfig5),

RuleConfig9 = #{min_complexity => 9},
[_] = elvis_style:dont_repeat_yourself(ElvisConfig, FileFail, RuleConfig9),
Expand Down