Skip to content

Commit b659378

Browse files
committed
Add "Empty Strings In Interpolation" rule.
1 parent c72e8dc commit b659378

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4910,6 +4910,20 @@ message = "This is the #{result.to_s}."
49104910
message = "This is the #{result}."
49114911
----
49124912

4913+
=== Empty Strings In Interpolation [[empty-strings-in-interpolation]]
4914+
4915+
Don't assign empty strings inside string interpolation.
4916+
For conditionals, use modifier statements instead of ternaries with empty strings.
4917+
4918+
[source,ruby]
4919+
----
4920+
# bad
4921+
"#{condition ? 'foo' : ''}"
4922+
4923+
# good
4924+
"#{'foo' if condition}"
4925+
----
4926+
49134927
=== String Concatenation [[concat-strings]]
49144928

49154929
Avoid using `pass:[String#+]` when you need to construct large data chunks.

0 commit comments

Comments
 (0)