
In some cases, the `rule.adoc` at root of a rule is never included anywhere and thus is dead code. It's a maintenance cost by itself, but also it misses opportunities to inline code that seems used by two documents when in fact only one document is actually rendered. And this missed opportunity, in turn, stops us from applying the correct language tag on the code samples.
78 lines
2.1 KiB
Plaintext
78 lines
2.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The use of ``++self++`` is optional except when in closure expressions, and when it's needed to distinguish between property names and arguments. For the sake of brevity, ``++self++`` should be omitted when it's not strictly required.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,swift]
|
|
----
|
|
class Car {
|
|
var color: Int
|
|
|
|
init(color: Int) {
|
|
self.color = color
|
|
}
|
|
|
|
func fade() {
|
|
self.color-- // Noncompliant
|
|
}
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,swift]
|
|
----
|
|
class Car {
|
|
var color: Int
|
|
|
|
init(color: Int) {
|
|
self.color = color
|
|
}
|
|
|
|
func fade() {
|
|
color--
|
|
}
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove the "self" keyword.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== replaces: S3255
|
|
|
|
=== on 8 Jul 2015, 18:14:20 Ann Campbell wrote:
|
|
\[~elena.vilchik] note that I've converted this to a subtask of a rule with a more widely-applicable name. Since it's not implemented yet in Swift, I don't anticipate problems with that, but let me know if there are.
|
|
|
|
=== on 27 Jul 2015, 06:57:13 Elena Vilchik wrote:
|
|
\[~ann.campbell.2] Unfortunately, it was already implemented. So it's wrong rule key in release (S2963 instead of S3255). WDYT should be done to fix this inconsistency?
|
|
|
|
=== on 27 Jul 2015, 13:51:01 Ann Campbell wrote:
|
|
After discussion with [~elena.vilchik]:
|
|
|
|
Because Swift version had already been coded and released, this task became the parent, to preserve the rule key, and its contents swapped to the more generic ``++this++``. A new Swift subtask was created, preserving the original contents of this RSpec.
|
|
|
|
=== on 27 Jul 2015, 13:51:59 Ann Campbell wrote:
|
|
Do you want to look this over [~elena.vilchik] & make sure I didn't miss anything?
|
|
|
|
=== on 27 Jul 2015, 13:56:44 Elena Vilchik wrote:
|
|
\[~ann.campbell.2] i removed swift-specific message from parent. Otherwise looks good!
|
|
|
|
=== on 16 Nov 2015, 15:41:37 Tamas Vajk wrote:
|
|
This rule was untargeted for C#, because Visual Studio 2015 reports this to the user in the IDE by default. (The rule ID is IDE0003)
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|