-
Notifications
You must be signed in to change notification settings - Fork 0
Maintenance: SimpleQueryRewriter - Improve null safety and add comprehensive tests #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add consistent null and blank string handling in both methods - Replace informal Korean comments with proper Javadoc - Improve variable naming (s -> normalized) - Add isBlank() check to handle whitespace-only strings - Ensure both methods return empty string for invalid input This change improves code consistency and safety by ensuring both methods handle edge cases identically and provides better documentation for future maintainers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Test null, empty, and blank string handling - Test normalization: lowercase, space collapsing, trimming - Test Korean text handling - Test special character preservation - Test both rewrite() and expandForKeywords() methods - Test edge cases for both methods Tests ensure the SimpleQueryRewriter behaves correctly as a fallback implementation and handles all input edge cases safely. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
PR Review: SimpleQueryRewriter - Improvements and FeedbackOverall AssessmentRating: ✅ Approve with Minor Suggestions This is a solid maintenance PR that addresses real issues in the Code Quality & Best Practices✅ Strengths
💡 Suggestionssrc/main/java/spring/memewikibe/infrastructure/ai/SimpleQueryRewriter.java:23-26 The implementation uses if (query == null || query.isBlank()) {
return "";
}
// query.isBlank() is false here, so trim() will always produce non-empty result
String normalized = query.toLowerCase(Locale.ROOT).replaceAll("\\s+", " ").trim();
return normalized;Or more concisely: if (query == null || query.isBlank()) {
return "";
}
return query.trim().toLowerCase(Locale.ROOT).replaceAll("\\s+", " ").trim();The second Potential Bugs & Issues
|
Summary
Inspected and improved
SimpleQueryRewriter- a fallback implementation for query rewriting when AI services are unavailable.Issues Found
Inconsistent null handling:
rewrite()returned""for null inputexpandForKeywords()returned the original null valueMissing blank string checks:
nullbut not whitespace-only stringsPoor documentation:
Code clarity:
s->normalized)No test coverage:
Changes Made
SimpleQueryRewriter.java:
isBlank()checks to both methodsSimpleQueryRewriterTest.java (new):
rewrite()andexpandForKeywords()methodsWhy These Changes Improve the Code
All tests pass ✅
🤖 Generated with Claude Code