
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.
47 lines
2.0 KiB
Plaintext
47 lines
2.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Variables that are never updated will always return their default values and so they should be explicitly declared as constant. A ``++let++``-declaration guarantees and clearly signals to the programmer that its value is supposed to and will never change.
|
|
|
|
This rule applies to non-constant fields and variables which are not set within the codebase.
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Declare variable "{0}" with "let".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 15 May 2015, 11:57:27 Elena Vilchik wrote:
|
|
Consider only "set and read but never updated" variables and not "unused" one.
|
|
|
|
=== on 8 Oct 2014, 07:20:32 Nicolas Peru wrote:
|
|
\[~ann.campbell.2]Why non-private ?
|
|
|
|
=== on 8 Oct 2014, 12:16:15 Ann Campbell wrote:
|
|
\[~nicolas.peru] we already have a separate rule about private fields: RSPEC-1068, and because the advice is different. If they're private and not used, they're dead code. If they're not private and _apparently_ unused, they might still be accessed directly by classes that just aren't currently 'visible'.
|
|
|
|
=== on 10 Oct 2014, 14:15:18 Freddy Mallet wrote:
|
|
@Ann :
|
|
|
|
* I would use the label "pitfall"
|
|
* Moreover for me there is no intersection between this rule and rule RSPEC-1068. In case of RSPEC-1068 we're looking for unused fields whereas here we're looking for fields that ARE really used but never updated and so which should be declared as 'final'
|
|
* I would decrease the remediation cost to 2 min and associate this rule to the Maintainability > Understandability characteristic
|
|
* This rule would be limited at first to private fields but I would not mention this limitation
|
|
|
|
=== on 15 May 2015, 09:53:17 Elena Vilchik wrote:
|
|
\[~ann.campbell.2] I want to expand the scope of this rule for Swift "Fields *and variables* that are never updated should be constant". WDYT can I do it in subtask for this rule?
|
|
|
|
=== on 15 May 2015, 11:52:30 Ann Campbell wrote:
|
|
Fine with me [~elena.vilchik]
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|