S2698 suffers from multiple problems related to issue reporting that we should improve.
- duplicate issues:
This code will report one issue for each matches.
- the whole assertion is highlighted
Can we do better? Only highlight one method call?
- confusing behavior when the message is misplaced for fest assert (and AssertJ once
SONARJAVA-3349will be done)
claiming that a message is missing, it is not trivial to understand that it is actually misplaced.
RSPEC-5833 will report that "as()" will not be applied, but this rule could still report that it is misplaced (or simply say to add a message before the assertion). In addition, highlighting should be on the assertion method name. (isEqualTo() in this case)
- FP when a generic assertion is not an assertion predicate: