SONARJAVA-6330: Implement S8692 - The system clock should not be used in tests#5611
SONARJAVA-6330: Implement S8692 - The system clock should not be used in tests#5611aurelien-coet-sonarsource wants to merge 3 commits intomasterfrom
Conversation
a264a6e to
add8e7f
Compare
SummaryThis PR implements rule S8692: "The system clock should not be used in unit tests." The implementation adds a static analysis check that detects non-deterministic temporal method calls within test code. The check flags:
Compliant alternatives like A baseline update indicates the rule produces 0 false positives and 0 false negatives on the eclipse-jetty corpus. What reviewers should knowStart with:
Key design decisions:
Integration notes:
|
|
|
||
| @Override | ||
| protected void onMethodInvocationFound(MethodInvocationTree mit) { | ||
| reportIssue(mit, "Replace this use of the system clock with a fixed clock."); |
There was a problem hiding this comment.
Let's keep the message generic, so it also covers reading the clock to measure elapsed time..
|




No description provided.