Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Changed the Exceptions and Risk Assessment sections too the new Quality Tradeoff section

...

Code Block
bgColor#ccccFF
public class Example {
  private T a;   // purpose of a...
  private T b;   // purpose of b...
  private T[] c; // purpose of c[]...
  private T d;   // purpose of d...

  public Example(T in){
    a = in;
    b = in;
    c = (T[]) new Object[10];
    d = in;
  }
}

Exceptions

Quality Tradeoff

Declaration of multiple variables per line can reduce code readability and lead to programmer confusion.

DCL01-EX1: Note that the declaration of a loop counter in a for statement is in violation of this guideline because the declaration is not on its own line with an explanatory comment about the variable's role. However, declaration of loop indices in for statements is not only a common idiom but also provides the benefit of restricting the scope of the loop index to the for loop itself. This is a specific reason to relax this guideline.

...

Code Block
bgColor#ccccff
public class Example {
  void function() {
    int mx = 100; // some max value

    for (int i = 0; i < mx; ++i ) {
      /* ... */
    }

  }
}

Risk Assessment

Declaration of multiple variables per line can reduce code readability and lead to programmer confusion.

...

Guideline

...

Severity

...

Likelihood

...

Remediation Cost

...

Priority

...

Level

...

DCL54-JG

...

low

...

unlikely

...

low

...

...

L3

Related Guidelines

C Secure Coding Standard: DCL04-C. Do not declare more than one variable per declaration

...

 

DCL50-JG. Use visually distinct identifiers      01. Declarations and Initialization (DCL)      DCL59-JG. Avoid ambiguous overloading of varargs methods

Image Removed Image Removed Image Removed