Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a "version lens" CodeLens feature and supporting plumbing. Two new VS Code configuration keys ( Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
packages/language-service/src/utils/version.ts (1)
59-71: Consider handling invalid semver input gracefully.
new SemVer(resolvedVersion)on line 60 will throw aTypeErrorifresolvedVersionis not a valid semver string. Whilst the caller should ideally provide valid input, defensive handling would prevent runtime crashes when encountering malformed version specs.♻️ Suggested defensive handling
export function resolveUpgradeTiers(pkg: PackageInfo, resolvedVersion: string): UpgradeTier[] { + let current: SemVer + try { + current = new SemVer(resolvedVersion) + } + catch { + return [] + } - const current = new SemVer(resolvedVersion) const currentMajor = current.major const currentMinor = current.minorpackages/language-service/src/utils/version.test.ts (1)
28-33: Test helper usesascast; consider a type-safe alternative.The
as PackageInfocast on line 32 bypasses type checking. Whilst acceptable in test helpers, a more type-safe approach would usesatisfiesor provide complete mock data.♻️ Type-safe alternative using Partial
-function createPkg(versions: string[]): PackageInfo { +function createPkg(versions: string[]): Partial<PackageInfo> & Pick<PackageInfo, 'versionsMeta' | 'distTags'> { const versionsMeta: Record<string, object> = {} for (const v of versions) versionsMeta[v] = {} - return { versionsMeta, distTags: { latest: versions.at(-1)! } } as PackageInfo + return { versionsMeta, distTags: { latest: versions.at(-1)! } } }As per coding guidelines: "Avoid
astype casts—validate instead in TypeScript".extensions/vscode/src/commands/replace-text.ts (1)
4-15: Consider handlingapplyEditfailure.
workspace.applyEdit()returnsPromise<boolean>indicating whether the edit was applied successfully. Silently ignoring failures could lead to confusing user experiences when edits don't apply (e.g., file changed externally, read-only file).♻️ Suggested error handling
export async function replaceText(uri: string, range: LspRange, newText: string) { const edit = new WorkspaceEdit() edit.replace( Uri.parse(uri), new Range( new Position(range.start.line, range.start.character), new Position(range.end.line, range.end.character), ), newText, ) - await workspace.applyEdit(edit) + const success = await workspace.applyEdit(edit) + if (!success) { + throw new Error(`Failed to apply edit to ${uri}`) + } }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1cf001e9-a8a6-4365-a514-09e85dd1d164
📒 Files selected for processing (9)
extensions/vscode/README.mdextensions/vscode/package.jsonextensions/vscode/src/commands/replace-text.tsextensions/vscode/src/index.tspackages/language-service/src/index.tspackages/language-service/src/plugins/version-lens.tspackages/language-service/src/utils/version.test.tspackages/language-service/src/utils/version.tspackages/shared/src/commands.ts
close #2, close #32