2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-01-27 13:42:22 +01:00
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.
2020-12-21 15:38:52 +01:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2020-12-21 15:38:52 +01:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-12-21 15:38:52 +01:00
----
def fun():
'documentation string' # Compliant
print('Hello, world')
'Hello, world' # Noncompliant; has no effect
''' Long strings are ignored ''' # Compliant
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2020-12-21 15:38:52 +01:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-12-21 15:38:52 +01:00
----
def fun():
'documentation string' # Compliant
print('Hello, world')
''' Long strings are ignored ''' # Compliant
----
2022-01-25 18:36:46 +01:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Remove this useless string.
2022-01-25 18:36:46 +01:00
'''
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== on 24 Apr 2015, 09:08:47 Elena Vilchik wrote:
\[~ann.campbell.2] Please check description, i made some small changes
=== on 28 Apr 2015, 15:37:31 Ann Campbell wrote:
looks good [~elena.vilchik]
2022-01-25 18:36:46 +01:00
endif::env-github,rspecator-view[]