SONARJAVA-6208 S2699: Add approve to assertion method name pattern#5570
SONARJAVA-6208 S2699: Add approve to assertion method name pattern#5570NoemieBenard wants to merge 6 commits intomasterfrom
Conversation
SummaryThis PR extends rule S2699 (test method contains assertions) to recognize ApproveJ's The implementation includes:
What reviewers should knowStart here: Review the pattern change in Test coverage: The new Note: The false negatives metric increased by 1, which reflects a test case that was previously flagged but is now correctly handled by the enhanced pattern detection.
|
Co-authored-by: sonar-review-alpha[bot] <266116024+sonar-review-alpha[bot]@users.noreply.github.com>
tomasz-tylenda-sonarsource
left a comment
There was a problem hiding this comment.
Overall this change looks good, but we should also update the documentation in RSpec. Let me know when you have time and I'll show you how to do this.
| <artifactId>core</artifactId> | ||
| <version>1.6.0</version> | ||
| <scope>test</scope> | ||
| </dependency> |
There was a problem hiding this comment.
Please fix formatting.
|
| "hasTruePositives": true, | ||
| "falseNegatives": 157, | ||
| "falseNegatives": 158, | ||
| "falsePositives": 1 |
There was a problem hiding this comment.
The false negatives count went up by 1 (157 → 158) after adding approve to the pattern. This suggests the autoscan corpus contains at least one test method that calls something like approveOrder() or approvePayment() — a business-logic domain method that the rule now silently treats as an assertion, causing it to miss a genuine missing-assertion issue.
The word approve is broad enough to appear in non-assertion domain methods inside test code. Is this increase expected/acceptable as a deliberate trade-off, or is it a signal that the pattern should be narrowed (e.g. via a type-based check anchored to org.approvej, similar to how other frameworks are handled)?
- Mark as noise





Add approve keyword to the assertion methods pattern to support ApproveJ library