rspec/rules/S2957/swift/rule.adoc

49 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
When a closure contains only a ``++return++`` statement, the ``++return++`` itself can be omitted.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
someList.sort { a, b in
return a > b
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
someList.sort { a, b in a > b }
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the "return" keyword.
'''
== Comments And Links
(visible only on this page)
=== on 20 May 2015, 18:13:45 Ann Campbell wrote:
\[~elena.vilchik] I suspect a standard "for greater readability" argument is expected here, but it's hard for me to make it. Feel free to add it yourself. :-)
=== on 21 May 2015, 07:13:19 Elena Vilchik wrote:
\[~ann.campbell.2] what do you mean "argument"? Anyway I looks good to me now :)
=== on 3 Feb 2016, 17:11:53 Ann Campbell wrote:
\[~elena.vilchik] I just now saw your response (doh!). In this case "argument" == "reason".
endif::env-github,rspecator-view[]