Skip to content

Commit

Permalink
Merge pull request #187 from z8674558/more-opr
Browse files Browse the repository at this point in the history
  • Loading branch information
Brujo Benavides authored Mar 21, 2021
2 parents 32f7b84 + b833d81 commit 154b89e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ macro_module_names(Config, Target, RuleConfig) ->
-type operator_spaces_config() :: #{ ignore => [ignorable()]
, rules => [{right | left, string()}]
}.
-define(PUNCTUATION_SYMBOLS, [',', ';', 'dot', '->', ':', '::']).
-define(PUNCTUATION_SYMBOLS, [',', ';', 'dot', '->', ':', '::', '|', '||']).

-spec operator_spaces(elvis_config:config(),
elvis_file:file(),
Expand Down
8 changes: 8 additions & 0 deletions test/examples/fail_operator_spaces.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
, function5/0
, function6/0
, function7/0
, function8/0
, function9/0
, tag_filters/2
, unicode_characters/0
, this/0
Expand Down Expand Up @@ -53,6 +55,12 @@ function7() ->
RegExp = "^.{1,20}$",
re:run(Name, RegExp, [unicode]).

function8() ->
[should| [fail]] ++ [should |[fail]] ++ [shouldnot | [fail]].

function9() ->
[X|| X <- [fail]] ++ [X ||X <- [fail]] ++ [X || X <- [notfail]].

tag_filters(DocName, #{conn := Conn} = State) ->
TableName = atom_to_list(DocName),
Sql = ["SELECT "
Expand Down
14 changes: 12 additions & 2 deletions test/style_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,23 @@ verify_operator_spaces(Config) ->
Arrow = #{rules => [{left, "->"}]},
[] = elvis_core_apply_rule(Config, elvis_style, operator_spaces, Arrow, Path),

BarOptions = #{rules => [{right, "|"}, {left, "|"}]},
[_, _] = elvis_core_apply_rule(Config, elvis_style, operator_spaces, BarOptions, Path),

ComprehensionOperation = #{rules => [{right, "||"}, {left, "||"}]},
[_, _] = elvis_core_apply_rule(Config, elvis_style, operator_spaces, ComprehensionOperation, Path),

AllOptions = #{rules => [{right, ","},
{right, "++"},
{left, "++"},
{right, "+"},
{left, "+"},
{left, "->"}]},
[_, _, _, _, _, _] =
{left, "->"},
{right, "|"},
{left, "|"},
{right, "||"},
{left, "||"}]},
[_, _, _, _, _, _, _, _, _, _] =
elvis_core_apply_rule(Config, elvis_style, operator_spaces, AllOptions, Path).

-spec verify_operator_spaces_latin1(config()) -> any().
Expand Down

0 comments on commit 154b89e

Please sign in to comment.