Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
test: make common.noop a getter#12732
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Make `common.noop` a getter that returns a new function object each time the propery is read, not the same one. The old behavior could possibly lead to subtle and hard to catch bugs in some cases. Refs: nodejs#12711 (comment)
Trott 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.
LGTM if CI is green. I'd be just as happy (maybe even slightly happier) to get rid of common.noop altogether, but this works for me!
aqrln commented Apr 28, 2017
| constassert=require('assert'); | ||
| constevents=require('events'); | ||
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.
Whoops, unintentional style change. I think I had written something there and then deleted too much.
not-an-aardvark commented Apr 28, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I don't have a strong opinion on this change either way, but if |
Fishrock123 commented Apr 28, 2017
What if we |
| Object.defineProperty(exports,'noop',{ | ||
| enumerable: true, | ||
| get: ()=>()=>{} | ||
| }); |
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.
How about keeping the old noop and add
export.newNoop = () =>{return () =>{}}; refack commented Apr 28, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
+0.5 |
benjamingr commented Apr 29, 2017
I think at this point writing |
Fishrock123 commented Apr 29, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Even better, we should adjust our lint rules to allow unused arrow fn parameters to be |
refack commented Apr 29, 2017
@Fishrock123 although |
jasnell commented Apr 29, 2017
It was just added. A key reason I added this was to make it explicit that the function in question is intentionally a non-op. I'm definitely -1 on reverting back to the old approach. I'm also perfectly fine with cases that are better off not using I'm -1 on this PR. |
benjamingr commented Apr 29, 2017
I'd just like to point out JavaScript already ships with a well known I still think a syntactical construct (like () =>{}) or a built in (like Function.prototype) are clearer - but honestly all these ways are pretty obvious anyway and I don't think there is very much to gain/lose here. |
aqrln commented Apr 29, 2017
@jasnell should we then maybe warn about the difference between |
not-an-aardvark commented Apr 29, 2017
To me, it seems like if we have to document the gotchas of a noop function, it's already more trouble than it's worth. |
aqrln commented May 4, 2017
I think at this point this PR is superseded by #12822, so I'm going to go ahead and close it to clean up the backlog of PRs a bit :) Reopening is cheap if there ever be a need to do so. |
Make
common.noopa getter that returns a new function object each timethe propery is read, not the same one. The old behavior could possibly
lead to subtle and hard to catch bugs in some cases.
Refs: #12711 (comment)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test