For some statements in my code Clover reports "No Coverage information gathered for this expression". What does that mean?

Q: For some statements in my code Clover reports "No Coverage information gathered for this expression". What does that mean?
Clover will not measure coverage of a conditional expression if it contains an assignment operator. In practice we have found this only a minor limitation. To understand why Clover has this limitation, consider the following (very contrived) code fragment:


1  public int foo(int i) {
2    int j;
3    if ((j = i) == 1) {
4      return j;
5    }
6    return 0;
7  }
\\
at (2) the variable "j" is declared but not initialised.
at (3) "j" is assigned to inside the expression
at (4) "j" is referenced.

During compilation, most compilers can inspect the logic of the conditional at (3) to determine that "j" will be initialized by the time it is referenced (4), since evaluating the expression (3) will always result in "j" being given a value. So the code will compile. But Clover has to rewrite the conditional at (3) so that it can measure coverage, and the rewritten version makes it harder for compilers to infer the state of "j" when it is referenced at (4). This means that the instrumented version may not compile. For this reason, Clover scans conditionals for assignment. If one is detected, the conditional is not instrumented.

Last modified on May 26, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.