refactor: Replace !=/== tesSuccess with using isTesSuccess - #6409
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the codebase to replace direct comparisons with tesSUCCESS (i.e., != tesSUCCESS and == tesSUCCESS) with calls to the isTesSuccess() helper function. This is a code cleanup refactoring aimed at improving code consistency and readability.
However, the automated refactoring introduced several critical syntax errors and type mismatches that will prevent compilation:
- Syntax errors in three files where the negation operator was incorrectly placed
- Type mismatches in XChainBridge.cpp where
std::optional<TER>values are passed toisTesSuccess()which expectsTER
Changes:
- Replaced
== tesSUCCESSwithisTesSuccess() - Replaced
!= tesSUCCESSwith!isTesSuccess() - Applied changes across transaction transactors, invariant checks, and protocol files
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libxrpl/tx/transactors/XChainBridge.cpp | Refactored success checks but introduced critical bugs with optional types |
| src/libxrpl/tx/transactors/SetTrust.cpp | Refactored permission check |
| src/libxrpl/tx/transactors/SetSignerList.cpp | Refactored preflight and preclaim checks |
| src/libxrpl/tx/transactors/Payment.cpp | Refactored multiple authorization and result checks |
| src/libxrpl/tx/transactors/Offer/CreateOffer.cpp | Refactored offer creation success checks |
| src/libxrpl/tx/transactors/NFT/NFTokenUtils.cpp | Refactored trustline authorization checks |
| src/libxrpl/tx/transactors/NFT/NFTokenMint.cpp | Refactored token insertion check |
| src/libxrpl/tx/transactors/NFT/NFTokenAcceptOffer.cpp | Refactored multiple authorization and payment checks |
| src/libxrpl/tx/transactors/MPT/MPTokenIssuanceSet.cpp | Refactored permission check |
| src/libxrpl/tx/transactors/Escrow.cpp | Refactored multiple authorization checks |
| src/libxrpl/tx/transactors/DeleteAccount.cpp | Refactored cleanup result check |
| src/libxrpl/tx/transactors/Check/CashCheck.cpp | Refactored flow result checks |
| src/libxrpl/tx/transactors/Batch.cpp | Refactored preflight check but introduced syntax error |
| src/libxrpl/tx/transactors/AMM/AMMWithdraw.cpp | Refactored withdrawal and deletion checks |
| src/libxrpl/tx/transactors/AMM/AMMUtils.cpp | Refactored trustline deletion check |
| src/libxrpl/tx/transactors/AMM/AMMDeposit.cpp | Refactored deposit result checks |
| src/libxrpl/tx/transactors/AMM/AMMDelete.cpp | Refactored deletion result check |
| src/libxrpl/tx/transactors/AMM/AMMCreate.cpp | Refactored creation authorization and send checks |
| src/libxrpl/tx/transactors/AMM/AMMClawback.cpp | Refactored clawback application checks |
| src/libxrpl/tx/transactors/AMM/AMMBid.cpp | Refactored bid result checks |
| src/libxrpl/tx/paths/Flow.cpp | Refactored flow result check but introduced syntax error |
| src/libxrpl/tx/applySteps.cpp | Refactored preclaim check but introduced syntax error |
| src/libxrpl/tx/Transactor.cpp | Refactored apply and fee payment checks |
| src/libxrpl/tx/InvariantCheck.cpp | Refactored multiple invariant result checks |
| src/libxrpl/protocol/NFTokenOfferID.cpp | Refactored transaction result check |
| src/libxrpl/protocol/NFTokenID.cpp | Refactored transaction result check |
| src/libxrpl/ledger/View.cpp | Refactored multiple credit and send result checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #6409 +/- ##
=======================================
Coverage 79.8% 79.8%
=======================================
Files 878 878
Lines 68030 68031 +1
Branches 7558 7551 -7
=======================================
+ Hits 54296 54314 +18
+ Misses 13734 13717 -17
🚀 New features to boost your workflow:
|
godexsoft
left a comment
There was a problem hiding this comment.
this is an obvious win.
One thing that i like to do is to write 'not' instead of '!' when it makes the condition read more like plain English. This is of course optional and a matter of taste so feel free to ignore 👍
This change replaces all instances of `<variable> != tesSUCCESS` with `!isTesSuccess(<variable>)` and `<variable> == tesSUCCESS` with `isTesSuccess(<variable>)`.
High Level Overview of Change
This PR replaces all instances of
<variable> != tesSUCCESSwith!isTesSuccess(<variable>)and<variable> == tesSUCCESSwithisTesSuccess(<variable>).Context of Change
General code cleanup
Type of Change
API Impact
N/A
Test Plan
CI passes.