rspec/rules/S2848/rule.adoc

24 lines
755 B
Plaintext
Raw Normal View History

There is no point in adding unused strings to the code. If the first line of a function or a class is a string, it's considered documentation, but otherwise short strings (enclosed in single quotes `+'+` or double quotes `+"+`) that aren't either assigned to variables or used in function calls or expressions are considered confusing cruft, and should be removed.
== Noncompliant Code Example
----
def fun():
'documentation string' # Compliant
print('Hello, world')
'Hello, world' # Noncompliant; has no effect
''' Long strings are ignored ''' # Compliant
----
== Compliant Solution
----
def fun():
'documentation string' # Compliant
print('Hello, world')
''' Long strings are ignored ''' # Compliant
----