Skip to content
Permalink
Browse files

Fix behaviour of StringSigils

  • Loading branch information...
rrrene committed Mar 30, 2019
1 parent f2a30e1 commit f9d5ee4e1345981e0b323ae6b04c2ff351779620
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/credo/check/readability/string_sigils.ex
@@ -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(

0 comments on commit f9d5ee4

Please sign in to comment.
You can’t perform that action at this time.