== Why is this an issue? Calculating or retrieving a value only to then overwrite it or throw it away, could indicate a serious error in the code. Even if it's not an error, it is at best a waste of resources. Therefore all calculated values should be used. === Noncompliant code example [source,html] ---- void calculateRate(int a, int b) { int i; i = a + b; // Noncompliant; calculation result not used before value is overwritten i = doSomething(); // Noncompliant; retrieved value not used for (i = 0; i < 10; i++) { // ... } // ... } ---- === Compliant solution [source,html] ---- void calculateRate(int a, int b) { int i; i = doSomething(); i += a + b; storeI(i) for (i = 0; i < 10; i++) { // ... } } ---- ifdef::env-github,rspecator-view[] ''' == Comments And Links (visible only on this page) === duplicates: S1854 === on 19 Sep 2014, 13:54:47 Freddy Mallet wrote: @Ann, I would: * Associated this rule to CWE-563: \http://cwe.mitre.org/data/definitions/563.html * Use the SQALE "Reliability" characteristic because again when there is a potential operational risk, this is more important than anything else * Add the tag "Bug" endif::env-github,rspecator-view[]