rspec/rules/S3668/swift/rule.adoc

39 lines
664 B
Plaintext
Raw Normal View History

== Why is this an issue?
In the interests of clean code, getters should be implicit, rather than explicit for properties that have only getters.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,swift]
----
var luckyNumber: Int {
get { // Noncompliant
return 7
}
}
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,swift]
----
var luckyNumber: Int {
return 7
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== duplicates: S2962
=== on 8 Jul 2016, 19:29:50 Ann Campbell wrote:
https://github.com/github/swift-style-guide#prefer-implicit-getters-on-read-only-properties-and-subscripts
endif::env-github,rspecator-view[]