2023-10-17 09:45:51 +02:00
|
|
|
:identifier_capital_plural: Local variables and function parameters
|
|
|
|
:identifier: local variable and function parameter
|
|
|
|
:identifier_plural: local variables and function parameters
|
|
|
|
:identifier_or: local variable or function parameter
|
|
|
|
:regex: ^[a-z][a-zA-Z0-9]*$
|
|
|
|
|
2020-06-30 10:16:44 +02:00
|
|
|
include::../rule.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
=== Code examples
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
==== Noncompliant code example
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
With the default regular expression ``{regex}``:
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
[source,swift,diff-id=1,diff-type=noncompliant]
|
|
|
|
----
|
|
|
|
func printSomething(param_:String){ // Noncompliant
|
|
|
|
var Text = "df" // Noncompliant
|
|
|
|
Text = Text + param_
|
|
|
|
print(Text)
|
|
|
|
}
|
|
|
|
----
|
2023-05-25 14:18:12 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
==== Compliant solution
|
2023-05-25 14:18:12 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
[source,swift,diff-id=1,diff-type=compliant]
|
2023-05-25 14:18:12 +02:00
|
|
|
----
|
2023-10-17 09:45:51 +02:00
|
|
|
func printSomegtthing(param:String){
|
|
|
|
var text = "df"
|
|
|
|
text = text + param
|
|
|
|
print(text)
|
|
|
|
}
|
2023-05-25 14:18:12 +02:00
|
|
|
----
|
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
== Resources
|
|
|
|
|
|
|
|
=== Documentation
|
|
|
|
|
|
|
|
* Microsoft - https://microsoft.github.io/swift-guide/Naming.html[Swift Guide - Naming Conventions]
|
|
|
|
* Wikipedia - https://en.wikipedia.org/wiki/Naming_convention_(programming)[Naming Convention (programming)]
|
|
|
|
|
|
|
|
=== Articles & blog posts
|
|
|
|
|
|
|
|
* Betterprogramming - https://betterprogramming.pub/naming-conventions-in-swift-4b7ca5eed4d2[Naming Conventions in Swift]
|
|
|
|
* Mobomo - https://www.mobomo.com/2017/03/naming-conventions-for-swift/[Style Guide: Swift Naming Conventions
|
|
|
|
]
|
|
|
|
|
|
|
|
=== Related rules
|
|
|
|
|
|
|
|
* S100 - Function names should comply with a naming convention
|
|
|
|
* S101 - Class names should comply with a naming convention
|
|
|
|
* S114 - Protocol names should comply with a naming convention
|
|
|
|
* S115 - Constant names should comply with a naming convention
|
|
|
|
* S116 - Field names should comply with a naming convention
|
|
|
|
* S119 - Type parameter names should comply with a naming convention
|
|
|
|
* S1642 - `struct` names should comply with a naming convention
|
|
|
|
* S2342 - Enumeration types should comply with a naming convention
|
|
|
|
* S2343 - Enumeration members should comply with a naming convention
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
2023-05-25 14:18:12 +02:00
|
|
|
|
2023-10-17 09:45:51 +02:00
|
|
|
include::../parameters.adoc[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|