-
Notifications
You must be signed in to change notification settings - Fork 374
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
Remove lodash.noop lib dependency #126
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
Coverage remained the same at 94.233% when pulling 0d4df2c96716b16741852c1411fa37721271fae1 on SkeLLLa:feature/remove-useless-lib into 642fba8 on google:master. |
Why |
|
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!
From a var noop = function () {};
var noop = new Function();
var noop = Function();
var noop = Function;
var noop = Function.prototype; Correction: These would all work fine if you were to pass them to say, |
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.
After taking a closer look at how noop
is used in the code (it's possible it might receive an Error
instance), I think you should switch to one of the following:
var noop = function () {};
var noop = Function();
var noop = new Function();
var noop = Function.prototype;
Why not create and use a named, static noOp in |
With Ultimately though, I don't think this lib should be using noop at all, the callback should be mandatory (breaking change) where the lib is currently falling back to the noop. |
@cristiancavalli usually in my libs I prefer to set once Also I think So if |
@jmdobry What is the problem making noOp in utils? It's a util right? |
@cristiancavalli as I've wrote using global.noop is not an option for a public library. Also using As for implementing in some module a simple noop function will require to add |
also @jmdobry Every single file in this PR already requires util.js except for |
@SkeLLLa All the files (save 1) in this PR already requires util |
Also @SkeLLLa not sure how using a third-party module is an anti-pattern? Even for something like noOp. Whereas this copy-paste solution seems like a classic case of abstraction inversion to me on the class level |
@cristiancavalli as for me it's definite antipattern to require module that doesn't contain any logic and have only one line of code that could be easilly replaced by one line in simple javascript code. It's like adding two numbers in js with help of jquery |
@SkeLLLa I understand your complaint - I've had it many times myself and I think subbing out lodash.noOp is better than keeping it in but I don't what you're citing is an anti-pattern. An inefficiency? Totally. Violating any rules of abstraction/inheritance/relation? I can't see any, but I may not be seeing it |
Remove useless noop lib Remove useless noop lib
0c3daa8
to
415cad7
Compare
I'm fine with either option in this case, but @cristiancavalli makes a good point that the files are already importing |
@jmdobry file https://github.com/google/google-auth-library-nodejs/blob/master/lib/auth/jwtaccess.js isn't importing utils |
@SkeLLLa Just by LOC, even with the change to jwtaccess.js for utils, you'd still come in under the current change footprint. (just sayin') |
Alright folks, just took a closer look at the code, and |
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
Thanks @SkeLLLa !! |
@cristiancavalli as for antipatterns - each module you require contains "risk". Even such little module as noop. Also noop module contains only one function that's already exist in javascript out-of-the-box. It makes no sense to write a separate module that will export something like module.exports = Array.prototype.map; The same with noop. But it's my point of view. @cristiancavalli, @jmdobry Thanks tou you, too. |
Lodash noop lib is useless and it's better to use just:
Because of following reasons: