rspec/rules/S1186/swift/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

55 lines
1.1 KiB
Plaintext

== Why is this an issue?
There are several reasons for a function or closure not to have a body:
* It is an unintentional omission, and should be fixed to prevent unexpected behavior in production.
* It is not yet, or never will be, supported. In this case an exception should be thrown.
* The function is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
=== Noncompliant code example
[source,swift]
----
func fun(p1:Int) {
}
----
=== Compliant solution
[source,swift]
----
func fun(p1:Int) {
var a = doSomething(p1)
var threshold = 42
if a > threshold {
// ...
}
}
----
or
[source,swift]
----
func fun(p1:Int) {
// Intentionally unimplemented...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add a nested comment explaining why this [function|closure] is empty, or complete the implementation.
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]