-
Notifications
You must be signed in to change notification settings - Fork 30k
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
http: remove pointless uses of arguments #10664
Conversation
With the http changes for example, the error messages now no longer reflect what is being tested, so they would need to be changed. Either way those http changes might be semver-major because of the change in behavior? |
I was trying to avoid semver-major, but I can make that change. If |
+1 for the early error but the message should be updated to say that a string is required |
@@ -382,7 +382,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) { | |||
|
|||
|
|||
OutgoingMessage.prototype.getHeader = function getHeader(name) { | |||
if (arguments.length < 1) { | |||
if (typeof name !== 'string') { |
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.
hmm... I think this technically makes this a semver-major because of the change in why the error is thrown, although there would be no way of triggering that difference so it likely wouldn't matter. Therefore I'm +1 with this part as semver-patch
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.
What do you mean? If someone does getHeader(undefined)
for example it now throws a different error. An argument was supplied, now it's just the wrong type.
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.
Good point... hmmm... yeah, there may not be a way around making this a semver-major
Changing the message to indicate that a string is required would force it to be semver-major |
I'm going to update the error and make it an uncontroversial semver major. |
if (arguments.length < 1) { | ||
throw new Error('"name" argument is required for getHeader(name)'); | ||
if (typeof name !== 'string') { | ||
throw new Error('"name" argument must be a string'); |
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.
TypeError
A new/updated test may be worthwhile also |
PR-URL: nodejs#10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#10664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
lib
Use of
arguments
generally only causes problems. This PR removes several uses that serve no purpose at all.