41 lines
1.0 KiB
Plaintext
41 lines
1.0 KiB
Plaintext
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
|
|
|
|
[source,text]
|
|
----
|
|
def fun():
|
|
'documentation string' # Compliant
|
|
print('Hello, world')
|
|
'Hello, world' # Noncompliant; has no effect
|
|
''' Long strings are ignored ''' # Compliant
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,text]
|
|
----
|
|
def fun():
|
|
'documentation string' # Compliant
|
|
print('Hello, world')
|
|
''' Long strings are ignored ''' # Compliant
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|