chore: use more fitting ignore case method#5980
Conversation
WalkthroughReplaced Unicode lowercasing string comparison with ASCII-only case-insensitive comparison in evaluate_test_success for the PassWithIdenticalErrorCaseInsensitive path. No other logic, control flow, or public interfaces were modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/tool/subcommands/api_cmd/api_compare_tests.rs (4)
3086-3088: Switch to eq_ignore_ascii_case removes allocations; confirm ASCII-only semantics are acceptable.This change avoids two temporary String allocations and is the right tool for ASCII-only case-insensitive comparison. It does change semantics vs Unicode lowercasing. Given our error texts appear to be English/ASCII (example at Lines 1181-1190), this looks safe. Consider adding a short code comment to prevent future regressions back to Unicode lowercasing.
Apply this diff to document the intent inline:
PolicyOnRejected::PassWithIdenticalErrorCaseInsensitive => { - reason_forest.eq_ignore_ascii_case(reason_lotus) + // ASCII-only case-insensitive compare avoids allocations from to_lowercase + // and is sufficient for our error strings (English / hex / base64). + // If non-ASCII ever shows up, revisit with Unicode casefolding. + reason_forest.eq_ignore_ascii_case(reason_lotus) }
200-208: Clarify variant semantics: explicitly note ASCII-only case-insensitivity.The name is generic, but the new implementation is ASCII-specific. A brief doc comment on the enum variant will help readers and keep tests aligned.
pub(super) enum PolicyOnRejected { Fail, Pass, PassWithIdenticalError, - PassWithIdenticalErrorCaseInsensitive, + /// Case-insensitive comparison using ASCII rules (no Unicode casefolding). + /// Chosen to avoid temporary allocations in hot paths. + PassWithIdenticalErrorCaseInsensitive, /// If Forest reason is a subset of Lotus reason, the test passes. /// We don't always bubble up errors and format the error chain like Lotus. PassWithQuasiIdenticalError, }
396-405: Align TestDump behavior with its documentation (only produce dump when invalid).Doc at Lines 188-198 says the dump is “Optional … if either status was invalid,” but here we always set
Some. If not intentional, gate it on success to reduce disk I/O and noise.TestResult { forest_status, lotus_status, - test_dump: Some(TestDump { - request: self.request.clone(), - forest_response, - lotus_response, - }), + test_dump: if !(matches!(forest_status, TestSummary::Valid) + && matches!(lotus_status, TestSummary::Valid)) + { + Some(TestDump { + request: self.request.clone(), + forest_response, + lotus_response, + }) + } else { + None + }, duration: start.elapsed(), }
1181-1188: Typo: “invocking” → “invoking”.Minor editorial fix in a user-facing comment.
- // Both Forest and Lotus should fail miserably at invocking Cthulhu's name + // Both Forest and Lotus should fail miserably at invoking Cthulhu's name
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/tool/subcommands/api_cmd/api_compare_tests.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: LesnyRumcajs
PR: ChainSafe/forest#5907
File: src/rpc/methods/state.rs:523-570
Timestamp: 2025-08-06T15:44:33.467Z
Learning: LesnyRumcajs prefers to rely on BufWriter's Drop implementation for automatic flushing rather than explicit flush() calls in Forest codebase.
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Summary by CodeRabbit