Skip to content

Commit

Permalink
Fix Code.to_tokens/1 for Elixir 1.6
Browse files Browse the repository at this point in the history
Refs #463, #469
  • Loading branch information
rrrene committed Nov 4, 2017
1 parent 9b338a8 commit 1eb501b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/credo/code.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,19 @@ defmodule Credo.Code do
|> to_tokens()
end
def to_tokens(source) when is_binary(source) do
{_, _, _, tokens} =
result =
source
|> Credo.Backports.String.to_charlist
|> :elixir_tokenizer.tokenize(1, [])

tokens
case result do
# Elixir < 1.6
{_, _, _, tokens} ->
tokens
# Elixir >= 1.6
{:ok, tokens} ->
tokens
end
end

defp issue_for({line_no, error_message, _}, filename) do
Expand Down

0 comments on commit 1eb501b

Please sign in to comment.