Skip to content

Commit

Permalink
Fix behaviour of StringSigils
Browse files Browse the repository at this point in the history
  • Loading branch information
René Föhring committed Mar 30, 2019
1 parent f2a30e1 commit f9d5ee4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/credo/check/readability/string_sigils.ex
Expand Up @@ -42,16 +42,21 @@ defmodule Credo.Check.Readability.StringSigils do

maximum_allowed_quotes = Params.get(params, :maximum_allowed_quotes, @default_params)

source_file
|> remove_heredocs()
|> Credo.Code.prewalk(&traverse(&1, &2, issue_meta, maximum_allowed_quotes))
case remove_heredocs_and_convert_to_ast(source_file) do
{:ok, ast} ->
Credo.Code.prewalk(ast, &traverse(&1, &2, issue_meta, maximum_allowed_quotes))

{:error, errors} ->
IO.warn("Unexpected error while parsing #{source_file.filename}: #{inspect(errors)}")
[]
end
end

defp remove_heredocs(source_file) do
defp remove_heredocs_and_convert_to_ast(source_file) do
source_file
|> SourceFile.source()
|> Heredocs.replace_with_spaces()
|> SourceFile.parse(source_file.filename)
|> Credo.Code.ast()
end

defp traverse(
Expand Down

0 comments on commit f9d5ee4

Please sign in to comment.