exercism / elixir-analyzer

GNU Affero General Public License v3.0
31 stars 32 forks source link

Look for multiline strings in high-school-sweetheart #230

Closed angelikatyborska closed 2 years ago

angelikatyborska commented 2 years ago

Closes https://github.com/exercism/elixir-analyzer/issues/86

i went for a very naive implementation that can be easily fooled by documentation, using multiline strings or just using any string that contains the heredoc syntax delimiters, e.g. ~s(""").

The module Code.Formatter is private and produces insane output that I don't want to parse... I don't want this check to break if we update Elixir versions.

I also gave up on writing a regex that would try to match that the string is inside of the correct function because a) I doubt my regex skills, b) that would produce false-positives when a private helper has the string.

Website copy PR: https://github.com/exercism/website-copy/pull/2130

angelikatyborska commented 2 years ago

Does 1.13's string_to_quoted_with_comments/2 also removes the mutliline structure?

yes 😢

iex(5)> single_line
"\"foo\\nbar\\n\"\n"
iex(6)> multi_line
"\"\"\"\nfoo\nbar\n\"\"\"\n"
iex(7)> Code.string_to_quoted_with_comments!(single_line)
{"foo\nbar\n", []}
iex(8)> Code.string_to_quoted_with_comments!(multi_line)
{"foo\nbar\n", []}
iex(9)> Code.string_to_quoted_with_comments!(single_line) == Code.string_to_quoted_with_comments!(multi_line)
true