refactor(ruby): idiomatic pass (Shopify Ruby + rubystyle)#223
Conversation
Greptile SummaryThis PR is a behavior-preserving idiomatic Ruby refactor of
Confidence Score: 5/5Safe to merge — every verification path, rejection condition, and error message is unchanged from the base branch. The diff is a single file, purely structural: frozen constant arrays replace inline anonymous arrays, three keyword_init Structs replace positional argument lists, and two factory helpers unify call sites. No conditional logic, guard clause, or error-path was added, removed, or reordered in a security-relevant way. The 465-test suite passes cleanly. No files require special attention. Important Files Changed
Reviews (4): Last reviewed commit: "refactor(ruby): idiomatic pass (Shopify ..." | Re-trigger Greptile |
| begin | ||
| rpc.account_owner(mint) | ||
| rescue => error | ||
| rescue ::PayCore::Solana::Rpc::RpcError, RuntimeError, KeyError, JSON::ParserError, TypeError => error |
There was a problem hiding this comment.
Explicit rescue list may miss network-level exceptions
The new rescue clause covers RpcError, RuntimeError, KeyError, JSON::ParserError, and TypeError, but Ruby's Errno::* family (e.g., Errno::ECONNREFUSED, Errno::ETIMEDOUT), Net::ReadTimeout, SocketError, and OpenSSL::SSL::SSLError are all StandardError subclasses that are not subclasses of RuntimeError. If ::PayCore::Solana::Rpc::RpcError does not wrap every low-level transport failure, those exceptions will now escape this block and surface as unhandled 500s instead of the clean Mpp::Error translation that the old bare rescue guaranteed. Please verify that RpcError wraps all failure modes of rpc.account_owner, or widen the list with the additional transport-layer exception classes.
Behavior-preserving idiomatic cleanup of the Ruby SDK MPP verifier: - mpp/protocol/solana/verifier.rb: explicit program tables (TOKEN_PROGRAMS / ALLOWED_PAYMENT_PROGRAMS), three keyword-init Struct value objects (TransferExpectation / SplTransferExpectation / AtaCreationPolicy), and keyword / value-object flow over long positional helper calls. Reject strings and verifier checks are unchanged. Verified: 465 runs 0 failures; standardrb clean.
|
Addressed the 4/5 review: reverted the |
3e1b7dd to
cb392c3
Compare
|
@greptile-apps please review |
Idiomatic-Ruby pass over the Ruby SDK MPP verifier (Shopify Ruby Style Guide + rubystyle.guide + the pay-kit Ruby review overlay). Behavior-preserving — reject strings and verifier checks are unchanged; verified by the full suite.
Stacked on #222 (
fix(ruby): ...): base isfix/ruby-security-hardeningso this PR shows only the idiomatic delta; it re-targets #219 once #222 merges. This is therefactor(<lang>)half of the per-language work.mpp/protocol/solana/verifier.rb: explicit program tables (TOKEN_PROGRAMS/ALLOWED_PAYMENT_PROGRAMS), threekeyword_initStructvalue objects (TransferExpectation/SplTransferExpectation/AtaCreationPolicy), and keyword / value-object flow over long positional helper calls.Scoped strictly to structural refactoring: the earlier
solana.rbrescuenarrowing was reverted after review (a behavior change belongs in afix(ruby), not a refactor), so the diff is a single file.Verified:
bundle exec rake test→ 465 runs, 0 failures;standardrbclean.