-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Develop #5239
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
base: master
Are you sure you want to change the base?
Develop #5239
Conversation
mateacademy-ai-mentor
left a comment
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.
Review Summary
Great job implementing the core logic for this function. You've correctly handled the state transformations and avoided mutation, which is excellent. However, a few changes are needed to fully align with the project's requirements.
Please make the following updates:
- Your
switchstatement is missing adefaultcase to handle unknown action types. This is required for robust error handling. [CHECKLIST ITEM #3] - The variable name
cloneshould be more descriptive. Please rename it to something likestateCopyto follow the naming guidelines. [CHECKLIST ITEM #5] - The JSDoc for the first parameter should be updated from
clonetostateto match the function signature.
Once these adjustments are made, your solution will be ready. Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
src/transformStateWithClones.js
Outdated
|
|
||
| /** | ||
| * @param {Object} state | ||
| * @param {Object} clone |
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.
The JSDoc here describes a parameter named clone, but the function's first parameter is actually state. Please make sure the documentation accurately matches the function signature.
src/transformStateWithClones.js
Outdated
| function transformStateWithClones(state, actions) { | ||
| // write code here | ||
| const arrStates = []; | ||
| const clone = { ...state }; |
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.
This violates checklist item #5: 'use proper names for object copy'. The checklist suggests using a more descriptive name like stateCopy instead of clone.
| switch (action.type) { | ||
| case 'addProperties': { | ||
| if (action.extraData && typeof action.extraData === 'object') { | ||
| Object.assign(clone, action.extraData); | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case 'removeProperties': { | ||
| if (Array.isArray(action.keysToRemove)) { | ||
| for (const key of action.keysToRemove) { | ||
| delete clone[key]; | ||
| } | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case 'clear': { | ||
| for (const key in clone) { | ||
| delete clone[key]; | ||
| } | ||
| break; | ||
| } | ||
| } |
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.
This violates checklist item #3: 'switch/case should always have default case for error handling.'. Your switch statement should include a default case to handle any unknown action types that might be passed in.
|
@ |
|
@mateacademy-ai-mentor |
mateacademy-ai-mentor
left a comment
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.
Review Summary
You're welcome, and thank you for the updates! You've done a great job improving the variable names and correcting the JSDoc.
This solution requires one final change. The switch statement is still missing a default case, which is required by the checklist to handle unknown action types [CHECKLIST ITEM #3]. As mentioned in the previous review, this is necessary for robust error handling.
Please add a default case to your switch statement. After that, your code will be perfect!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| switch (action.type) { | ||
| case 'addProperties': { | ||
| if (action.extraData && typeof action.extraData === 'object') { | ||
| Object.assign(newState, action.extraData); | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case 'removeProperties': { | ||
| if (Array.isArray(action.keysToRemove)) { | ||
| for (const key of action.keysToRemove) { | ||
| delete newState[key]; | ||
| } | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case 'clear': { | ||
| for (const key in newState) { | ||
| delete newState[key]; | ||
| } | ||
| break; | ||
| } | ||
| } |
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.
This switch statement is still missing a default case. This violates checklist item #3: 'switch/case should always have default case for error handling'. Please add a default case to handle any unknown action types.
|
@mateacademy-ai-mentor |
mateacademy-ai-mentor
left a comment
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.
Review Summary
You're very welcome! I'm glad the feedback was helpful.
Excellent work on this update! You've successfully addressed the previous feedback by adding the default case to your switch statement. Your solution is now complete, correct, and meets all the project requirements. I am happy to approve your submission. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.