Examples of errors detected by the V6021 diagnostic


V6021. The value is assigned to the 'x' variable but is not used.


SpotBugs

V6021 [CWE-563] The value is assigned to the 'old' variable but is not used. MergeSummarizeAndView.java 279


private void load() {
  ....
  long old = System.currentTimeMillis() - options.maxAge * (24 * 3600 * 1000L);
  if (options.baselineDate != null) {
    long old2 = options.baselineDate.getTime();
    if (old2 > old) {
      old = old2;
    }
  }
  .... // The 'old' variable is not used.
}

SpotBugs

V6021 [CWE-563] The value is assigned to the 'priority' variable but is not used. FindNonShortCircuit.java 197


private void reportBug() {
  int priority = LOW_PRIORITY;
  String pattern = "NS_NON_SHORT_CIRCUIT";

  if (sawDangerOld) {
    if (sawNullTestVeryOld) {
      priority = HIGH_PRIORITY;                                           // <=
    }
    if (sawMethodCallOld || sawNumericTestVeryOld && sawArrayDangerOld) {
      priority = HIGH_PRIORITY;                                           // <=
      pattern = "NS_DANGEROUS_NON_SHORT_CIRCUIT";
    } else {
      priority = NORMAL_PRIORITY;                                         // <=
    }
  }

  bugAccumulator.accumulateBug(
    new BugInstance(this, pattern, priority).addClassAndMethod(this), this);
}


Bugs Found

Checked Projects
343
Collected Errors
12 850