Skip to content

Commit 6bfbf8a

Browse files
authored
Merge pull request #317 from koic/add_prefer_squiggly_heredoc_rule
Add "Prefer using squiggly heredoc over `strip_heredoc`" rule
2 parents 7b91c8f + dde963d commit 6bfbf8a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,28 @@ hash.exclude?(:key)
16021602
string.exclude?('substring')
16031603
----
16041604

1605+
=== Prefer using squiggly heredoc over `strip_heredoc` [[prefer-squiggly-heredoc]]
1606+
1607+
If you're using Ruby 2.3 or higher, prefer squiggly heredoc (`<<~`) over Active Support's `strip_heredoc`.
1608+
1609+
[source,ruby]
1610+
----
1611+
# bad
1612+
<<EOS.strip_heredoc
1613+
some text
1614+
EOS
1615+
1616+
# bad
1617+
<<-EOS.strip_heredoc
1618+
some text
1619+
EOS
1620+
1621+
# good
1622+
<<~EOS
1623+
some text
1624+
EOS
1625+
----
1626+
16051627
=== Prefer `to_fs` for Formatted Strings [[prefer-to-fs]]
16061628

16071629
If you're using Rails 7.0 or higher, prefer `to_fs` over `to_formatted_s`. `to_formatted_s` is just too cumbersome for a method used that frequently.

0 commit comments

Comments
 (0)