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
Addressing-7747;-_.merge-=>-Object.assign #11267
Addressing-7747;-_.merge-=>-Object.assign #11267
Conversation
…cs.js; lib/plugins/invoke.js
done; lib/plugins/aws/package/compile/events/cloud-front.js
…nt.js as does deep merges + noted
some _.merge instance can't be replaced with Object.assgn; Those files are:
Some files had no tests, and so were not modifed; Those files are:
Some test files use _.merge, so those were skipped as they weren't in customer-facing code:
|
Codecov Report
@@ Coverage Diff @@
## main #11267 +/- ##
==========================================
- Coverage 85.89% 85.87% -0.03%
==========================================
Files 315 315
Lines 13247 13228 -19
==========================================
- Hits 11378 11359 -19
Misses 1869 1869
Continue to review full report at Codecov.
|
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.
Thanks a lot @pjmattingly - it looks good in general! I have a few comments, please let me know what do you think 🙇
@@ -12,7 +11,7 @@ class Config { | |||
} | |||
|
|||
update(config) { | |||
return _.merge(this, config); | |||
return Object.assign(this, config); |
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.
Did you validate that it's going to be a safe change? It seems like a pretty generic method where deep vs shallow copy behavior might have an impact
@@ -284,7 +284,7 @@ class Service { | |||
} | |||
|
|||
update(data) { | |||
return _.merge(this, data); | |||
return Object.assign(this, data); |
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.
Is it safe to use Object.assign
here? Is the deep merge not needed here?
@@ -346,7 +346,7 @@ class Service { | |||
|
|||
publish(dataParam) { | |||
const data = dataParam || {}; | |||
this.pluginsData = _.merge(this.pluginsData, data); | |||
this.pluginsData = Object.assign(this.pluginsData, data); |
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.
Is it safe to use Object.assign
here? Is the deep merge not needed here?
@@ -612,6 +612,7 @@ class AwsCompileCloudFrontEvents { | |||
|
|||
Object.assign(Resources, { [this.cloudFrontDistributionLogicalId]: CloudFrontDistribution }); | |||
|
|||
// #7747, could not replace _.merge with Object.assign, as this does deep merges |
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.
I think these assignments look pretty safe to be refactored - do you think we should keep merge here?
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.
@pgrzesik @pjmattingly with this change (while it's highly desirable) we need to be very careful.
If we touch not well tested areas it's possible we may introduce regressions, as behavior of _.merge
and Object.assign
differs.
Ideally, if each change is validated individually by looking through carefully what it does and what further logic it affects.
I would also add a comment in each case where we leave _.merge
usage with reasoning, on why _.merge
is wanted approach
@pjmattingly please confirm also by running integration tests, that we did not break anything
Will do.
I'll find my notes and add some more detail in comments for the unchanged ones.
I was working on #11273 and I found a need for inspecting objects during testing (See also: https://www.reddit.com/r/javascript/comments/w7ial4/askjs_a_library_for_tracking_the_properties_of_an/?). I think such functionality might also be helpful here, as the properties for the object can be tracked during (integration) testing. Would you agree? If so, then it might be worth making / finding code to track and report on the different values that effected objects go through and potentially where the code is called from. This way we can have more confidence about: 1) What properties and values the objects typically take and 2) What external code these changes touch. What do you think? |
I'm not sure if it's necessary to bundle such a thing into a test suite. It feels a bit overkill (and definitely adds to technical debt), but if in this specific case, it would help you test whether change is not breaking. Feel free to set up such thing temporarily (just to test proposed changes, but not be a part of a PR) |
Exactly. Thanks for weighing in!
…On Tue, Jul 26, 2022 at 1:43 AM Mariusz Nowak ***@***.***> wrote:
If so, then it might be worth making / finding code to track and report on
the different values that effected objects go through and potentially where
the code is called from.
I'm not sure if it's necessary to bundle such a thing into a test suite.
It feels a bit overkill (and definitely adds to technical debt), but if in
this specific case, it would help you test whether change is not breaking.
Feel free to set up such thing temporarily (just to test proposed changes,
but not be a part of a PR)
—
Reply to this email directly, view it on GitHub
<#11267 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABP7MZ7HYF4H7TIH24HDBK3VV6JLFANCNFSM54KPBF2Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Integration tests look good. Next, adding notes about why leaving in some
|
@pjmattingly once it's ready for re-review, it's best if you simply re-request review in right top box |
Okay, will do. I as making notes to show progress toward completion; It helps me remember what I was doing with this PR. Is that okay? |
Yes, that's totally good. Great thanks for helping on that one 👍 |
Addresses: #7747