feat: add Rust language to seed list - #24
Conversation
WalkthroughChangesRust language support
Seed duplicate handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for the PR! |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/features/snippets/logic/parsing/snippet-parser.server.ts (1)
23-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression tests for the Rust disabled ranges.
Cover line comments, block comments, lifetimes, loop labels, normal strings, raw strings, byte-prefixed literals, character literals, escaped delimiters, and empty literals. Include exact
startIndex/endIndexexpectations with delimiter exclusion and the same endpoint convention used bygetRandomSnippets().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/features/snippets/logic/parsing/snippet-parser.server.ts` around lines 23 - 42, Add regression tests for the Rust-specific range handling in the parser around the existing getRandomSnippets() behavior. Cover line_comment, block_comment, lifetime, loop_label, string_literal, raw_string_literal, byte-prefixed literals, char_literal, escaped delimiters, and empty literals, asserting exact startIndex/endIndex values with delimiters excluded and matching getRandomSnippets()’s endpoint convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@prisma/seed/files.ts`:
- Around line 75-81: Update the file seeding flow around fileVersion.create and
the final summary log to track successfully seeded files separately from
files.length. Initialize a counter before processing, increment it only after
fileVersion.create succeeds, and report that counter so duplicate files
returning null are excluded.
---
Nitpick comments:
In `@src/features/snippets/logic/parsing/snippet-parser.server.ts`:
- Around line 23-42: Add regression tests for the Rust-specific range handling
in the parser around the existing getRandomSnippets() behavior. Cover
line_comment, block_comment, lifetime, loop_label, string_literal,
raw_string_literal, byte-prefixed literals, char_literal, escaped delimiters,
and empty literals, asserting exact startIndex/endIndex values with delimiters
excluded and matching getRandomSnippets()’s endpoint convention.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ea0112f2-f2bd-491d-9f64-93ce898cabdc
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
lib/snippets/parsing/parser-factory.tsnext.config.tspackage.jsonprisma/seed/files.tssrc/features/snippets/logic/parsing/snippet-parser.server.ts
| console.warn(`Skipping duplicate file: ${file.repository}/${file.path}`); | ||
| return null; | ||
| } | ||
| throw error; | ||
| }); | ||
|
|
||
| if (!insertedFile) continue; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Report the number of files that were actually seeded.
When a duplicate returns null, this branch skips the file. The final log at Line 92 still reports files.length, so it counts skipped files as seeded files. Track a counter and increment it only after fileVersion.create succeeds.
Proposed fix
+ let seededCount = 0;
for (const file of files) {
...
await prisma.fileVersion.create({
...
});
+ seededCount += 1;
}
- console.log(`Seeded ${files.length} files for language: ${language.name}`);
+ console.log(`Seeded ${seededCount} files for language: ${language.name}`);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@prisma/seed/files.ts` around lines 75 - 81, Update the file seeding flow
around fileVersion.create and the final summary log to track successfully seeded
files separately from files.length. Initialize a counter before processing,
increment it only after fileVersion.create succeeds, and report that counter so
duplicate files returning null are excluded.
|
Thanks for adding it :) |
I really want Rust in code typer 🙏🙏
Adds Rust to the supported languages list so the seeder can fetch and populate Rust snippets from GitHub. This enables Rust in the language picker and game.
Summary by CodeRabbit
.rsfile recognition, syntax highlighting, and improved parsing of Rust syntax.