Skip to content

Commit

Permalink
Merge pull request #51 from jfacorro/jfacorro.343.op_spaces_fails_wit…
Browse files Browse the repository at this point in the history
…h_unicode

[Fix inaka/elvis#343] Use unicode module to convert utf8 binary to list
  • Loading branch information
Brujo Benavides committed May 16, 2016
2 parents 592a5d8 + 8d6f636 commit 8e24a61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ check_operator_spaces(Lines, Tokens, {Position, Operator}) ->
Operator::string(),
Location::{integer(), integer()}) -> char().
character_at_location(Position, Lines, Operator, {Line, Col}) ->
OperatorLineStr = binary_to_list(lists:nth(Line, Lines)),
OperatorLineStr = unicode:characters_to_list(lists:nth(Line, Lines)),
ColToCheck = case Position of
left -> Col - 1;
right -> Col + length(Operator)
Expand Down
23 changes: 15 additions & 8 deletions test/examples/fail_operator_spaces.erl
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
-module(fail_operator_spaces).

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

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

Expand Down Expand Up @@ -63,3 +65,8 @@ tag_filters(DocName, #{conn := Conn} = State) ->
{error, Error, _} ->
{error, Error, State}
end.

unicode_characters() ->
<<"©"/utf8>> = <<"\\u00A9">>,
<<"ß"/utf8>> = <<"\\o337">>,
ok.

0 comments on commit 8e24a61

Please sign in to comment.