Fix PR review comments: remove duplicates, fix dates, clean unused code, fix Redis SCAN bug#11
Conversation
Review completed. This PR addresses linting issues by removing unused imports and variables, fixing date formats in documentation, and cleaning up duplicate directories. One issue was identified in the redis-utils.ts file.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
…emove unused imports/vars Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com>
| async existsPattern(pattern: string): Promise<boolean> { | ||
| let cursor = '0'; | ||
|
|
||
| const [nextCursor, batch] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 10); | ||
| const [, batch] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 10); | ||
|
|
||
| return batch.length > 0; | ||
| } |
There was a problem hiding this comment.
The existsPattern method only performs a single SCAN operation and doesn't iterate through all matching keys. If the pattern matches keys beyond the first batch (COUNT=10), this will incorrectly return false even when matching keys exist. The method should either loop until cursor returns '0' or be documented as only checking the first batch.
Fix it with Roo Code or mention @roomote and request a fix.
|
@copilot , The existsPattern method only performs a single SCAN operation and doesn't iterate through all matching keys. If the pattern matches keys beyond the first batch (COUNT=10), this will incorrectly return false even when matching keys exist. The method should either loop until cursor returns '0' or be documented as only checking the first batch. |
Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com>
Fixed in |
|
@coderabbitai, review all work and provide final analysis. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 2746 🏁 Script executed: Length of output: 6949 🏁 Script executed: Length of output: 5595 @clduab11, I've completed a comprehensive review of all changes in PR #11. Here's the final analysis: ✅ All PR Objectives Successfully Implemented🔧 Critical Bug Fixes1. Redis // Before: Single scan operation (incorrect)
const [nextCursor, batch] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 10);
return batch.length > 0;
// After: Complete iteration with do...while loop (correct)
do {
const [nextCursor, batch] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
if (batch.length > 0) {
return true;
}
cursor = nextCursor;
} while (cursor !== '0');
return false;
📁 File Organization2. Duplicate Directory Removed - CONFIRMED
📅 Date Corrections3. Date Format Fixes - VERIFIED
🧹 Code Cleanup4. Logger Dependency Fix - VERIFIED // json-parser.ts now uses console fallback instead of Logger import
const logger = {
info: (...args: any[]) => console.info('[json-parser]', ...args),
warn: (...args: any[]) => console.warn('[json-parser]', ...args),
error: (...args: any[]) => console.error('[json-parser]', ...args),
debug: (...args: any[]) => console.debug('[json-parser]', ...args),
};5. Unused Imports Removed - ALL VERIFIED
6. Unused Variables Fixed - ALL VERIFIED
📊 Summary
🎯 ConclusionAll code review feedback has been thoroughly addressed. The critical Redis SCAN bug is now properly fixed with complete iteration logic, date formats are corrected, duplicate files are removed, and all unused imports/variables have been cleaned up. The codebase is cleaner and more maintainable. This PR is ready to merge. 🚀 If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
Addresses all code review feedback from the automated PR reviewer.
Duplicate files removed
backend/shared/backend/shared/directory containing duplicate sanitization utilitiesDate format corrections
2025-11-18, 11:59 PM CSTLogger dependency fix
Replaced external Logger import with console fallback in
json-parser.ts:Unused imports removed
gamification-service.test.ts:DEFAULT_SCORING_CONFIG,ScoringResultbase-tool.test.ts:ToolExecutionResultmcp-logging.test.ts:MCP_SANITIZATION_CONFIGsanitization.test.ts:DEFAULT_CONFIGmock-data-generator.test.ts:LeaderboardEntrycheck-comments.ts:pathUnused variables fixed
redis-utils.ts:nextCursor→[, batch]destructuringsanitization.ts:[type, pattern]→patternviaObject.values()check-doc-links.ts:[, text, link]→[, , link]destructuringRedis existsPattern bug fix
existsPatternmethod inredis-utils.tsto properly iterate through all SCAN resultsdo...whileloop to continue scanning until cursor returns '0'trueimmediately when matching keys are found,falseonly after exhausting the entire keyspace💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.