rspec/rules/S1845/swift/rule.adoc

40 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-01-27 13:42:22 +01:00
Looking at the set of methods in a ``++class++``, ``++struct++``, ``++enum++``, or ``++extension++`` and finding two methods that differ only by capitalization is confusing to users of the class. It is similarly confusing to have a method and a field or a case which differ only in capitalization.
2020-06-30 12:47:33 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2020-06-30 12:47:33 +02:00
----
class SomeClass {
var lookUp = false
func lookup(){ } // Noncompliant; method name differs from field name only by capitalization
func lookUP(){ } // Noncompliant; method name differs from field and another method name only by capitalization
}
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2020-06-30 12:47:33 +02:00
----
class SomeClass {
var lookUp = false
func getLookUp(){ }
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]