rspec/rules/S4185/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

54 lines
1.2 KiB
Plaintext

== Why is this an issue?
It is often considered good practice at the end of an override to invoke ``++super++``, but there are cases where according to the Apple developer documentation this should not be done.
* ``++updateLayer++`` - optimize the rendering of your view
* ``++loadView++`` - provide a ``++view++`` when ``++view++`` is ``++nil++``
* ``++providePlaceholder++`` - provide a placeholder for a document returned by the Document Picker but not yet stored locally
In all cases, these are actions that should happen once and only once. Subsequently invoking ``++super++`` would see your desired result replaced (at best) by less specialized results.
=== Noncompliant code example
[source,swift]
----
class VC: UIMyViewController {
override func loadView() {
// ...
super.loadView()
}
}
----
=== Compliant solution
[source,swift]
----
class VC: UIMyViewController {
override func loadView() {
// ...
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this call to "super.xxx()".
=== Highlighting
``++super.xxx()++``
endif::env-github,rspecator-view[]