Repository navigation
fix: strip parenthetical comments from depends-on parser - #642
Conversation
…Groups `depends-on: 1 (must be done first)` was parsed as dependency on "1 (must be done first)" which doesn't match any group. Now strips `(...)` suffixes from both the none-check and individual dep values.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
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 refines the dependency parsing logic within the Highlights
Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes the depends-on parser to correctly handle parenthetical comments. The changes in dispatch.ts introduce logic to strip these comments, and a new test case in dispatch.test.ts validates this behavior. The implementation in dispatch.ts is functionally correct but could be simplified to improve readability and remove redundancy. I've provided a suggestion to refactor the comment stripping logic.
| const depsNormalized = depsStr.replace(/\s*\([^)]*\)/g, '').trim(); | ||
| if (depsNormalized.toLowerCase() !== 'none') { | ||
| dependsOn = depsStr | ||
| .split(',') | ||
| .map((d) => d.trim().replace(/^group\s*/i, '')) | ||
| .map((d) => | ||
| d | ||
| .trim() | ||
| .replace(/^group\s*/i, '') | ||
| .replace(/\s*\(.*\)\s*$/, '') | ||
| .trim(), | ||
| ) | ||
| .filter(Boolean); | ||
| } |
There was a problem hiding this comment.
The logic for stripping parenthetical comments is a bit convoluted. It first creates depsNormalized by stripping comments from depsStr just for the 'none' check. Then, it processes the original depsStr and strips comments again inside the .map() call using a different regex.
This is redundant and can be simplified by cleaning the dependency string once and using that cleaned string for all subsequent logic. This would make the code easier to read and maintain.
const cleanedDepsStr = depsStr.replace(/\s*\([^)]*\)/g, '');
if (cleanedDepsStr.trim().toLowerCase() !== 'none') {
dependsOn = cleanedDepsStr
.split(',')
.map((d) =>
d
.trim()
.replace(/^group\s*/i, '')
.trim(),
)
.filter(Boolean);
}There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c195523d4a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| dependsOn = depsStr | ||
| .split(',') |
There was a problem hiding this comment.
Strip comments before splitting dependency list
When a depends-on comment contains a comma (for example Group 1 (setup, required), Group 2), this code splits on commas before removing parenthetical comments, so it produces invalid dependencies like "1 (setup" and "required)" instead of "1". That breaks dependency resolution in startGroup because those malformed IDs can never be satisfied. Removing parenthetical segments before .split(',') (or splitting only on commas outside parentheses) avoids corrupting the parsed dependency list.
Useful? React with 👍 / 👎.
Summary
parseWishGroups()indispatch.tsto strip parenthetical comments like(must be done first)fromdepends-onvaluesdepends-on: 1 (comment)now correctly parses as dependency on"1"instead of"1 (comment)"depends-on: none (comment)now correctly parses as no dependenciesWish
fix-depends-parserTest plan