-
Notifications
You must be signed in to change notification settings - Fork 12
fix(legacy-json): more robust signature parsing #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
==========================================
+ Coverage 71.55% 72.17% +0.62%
==========================================
Files 117 117
Lines 9726 9936 +210
Branches 590 597 +7
==========================================
+ Hits 6959 7171 +212
+ Misses 2764 2762 -2
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the signature parsing logic so that trailing brackets now correctly apply to the next parameter instead of the current one, and adds comprehensive parameterized tests across all related utility functions.
- Refactor
parseNameAndOptionalStatus
to extract the name and optional flag before adjusting depth for trailing brackets, with a clarifying comment. - Add parameterized test suites for
parseNameAndOptionalStatus
,parseDefaultValue
,findParameter
,parseParameters
, andparseSignature
to cover a wide range of scenarios.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/generators/legacy-json/utils/parseSignature.mjs | Moved name/optional extraction ahead of trailing-bracket depth update and added a clarifying comment |
src/generators/legacy-json/utils/tests/parseSignature.test.mjs | Introduced parameterized tests for all parsing helpers to improve coverage and consistency |
Comments suppressed due to low confidence (3)
src/generators/legacy-json/utils/parseSignature.mjs:42
- [nitpick] Consider adding a JSDoc comment above
parseNameAndOptionalStatus
to explain that trailing brackets are intentionally applied to the next parameter, clarifying the purpose of this refactor.
// Extract the actual parameter name
src/generators/legacy-json/utils/tests/parseSignature.test.mjs:279
- For signature tests where no return value is expected, add an explicit assertion that
result.return
isundefined
to guard against unintended default values in future changes.
it(testCase.name, () => {
src/generators/legacy-json/utils/parseSignature.mjs:43
- [nitpick] The variable
optionalDepth
is tracking depth for the next parameter; renaming it to something likenextOptionalDepth
throughout this function (and inparseParameters
) could reduce confusion about its role.
const actualName = parameterName.slice(startingIdx, endingIdx + 1);
Happy to fast-track :) 👍 |
@ovflowd I don't have my GPG key ( If not, I understand, and I can generate a temporary GPG key to sign my commits with, just let me know (I don't want to make us to anything insecure at my expense). |
Previously, the signature parsing would parse trailing brackets as if they affect the current parameter, rather than the next parameter.
Because of this,
mand[, opt]
would be seen as an optional param named "mand", and a mandatory parameter "opt". Now, trailing brackets correctly apply to the next parameter.