Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where 8-digit Chilean RUTs were not being formatted correctly. The core change involves adjusting the string splitting logic within the RUT formatting utility to ensure accurate presentation for these shorter numbers. Additionally, development dependencies have been updated to their latest versions, and the TypeScript configuration now includes source map generation. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes an issue with formatting 8-digit Chilean RUTs by using negative indices for splitting the string, which works for both 8 and 9-digit numbers. The change is accompanied by a new test case for the 8-digit format and updates to development dependencies. My review includes a suggestion to improve the robustness of the format function by adding input validation to prevent potential runtime errors when handling inputs of invalid length.
| const [value] = clean(input); | ||
|
|
||
| const [a, b, c, d] = strings.splitAt(value, 2, 5, 8); | ||
| const [a, b, c, d] = strings.splitAt(value, -7, -4, -1); | ||
|
|
||
| return `${a}.${b}.${c}-${d}`; |
There was a problem hiding this comment.
While the change to using negative indices in splitAt correctly handles both 8 and 9-digit RUTs, the format function is not robust against inputs of other lengths. If an input with a length other than 8 or 9 is provided (after cleaning), it can lead to a destructuring error. It would be safer to validate the length and also handle potential errors from clean(), similar to how compact() and validate() are implemented.
| const [value] = clean(input); | |
| const [a, b, c, d] = strings.splitAt(value, 2, 5, 8); | |
| const [a, b, c, d] = strings.splitAt(value, -7, -4, -1); | |
| return `${a}.${b}.${c}-${d}`; | |
| const [value, err] = clean(input); | |
| if (err) { | |
| throw err; | |
| } | |
| if (value.length < 8 || value.length > 9) { | |
| throw new exceptions.InvalidLength(); | |
| } | |
| const [a, b, c, d] = strings.splitAt(value, -7, -4, -1); | |
| return `${a}.${b}.${c}-${d}`; |
No description provided.