rspec/rules/S2848/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

51 lines
1.2 KiB
Plaintext

== Why is this an issue?
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)
=== Message
Remove this useless string.
'''
== Comments And Links
(visible only on this page)
=== 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]
endif::env-github,rspecator-view[]