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

Merged
merged 2 commits into from Jan 10, 2017

Conversation

Projects
None yet
6 participants
@cjihrig
Contributor

cjihrig commented Jan 6, 2017

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

lib

Use of arguments generally only causes problems. This PR removes several uses that serve no purpose at all.

@mscdex

This comment has been minimized.

Show comment
Hide comment
@mscdex

mscdex Jan 6, 2017

Contributor

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?

Contributor

mscdex commented Jan 6, 2017

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?

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig Jan 6, 2017

Contributor

I was trying to avoid semver-major, but I can make that change. If name isn't a string, toLowerCase() will crash later on in both functions.

Contributor

cjihrig commented Jan 6, 2017

I was trying to avoid semver-major, but I can make that change. If name isn't a string, toLowerCase() will crash later on in both functions.

@targos

This comment has been minimized.

Show comment
Hide comment
@targos

targos Jan 6, 2017

Member

+1 for the early error but the message should be updated to say that a string is required

Member

targos commented Jan 6, 2017

+1 for the early error but the message should be updated to say that a string is required

Show outdated Hide outdated lib/_http_outgoing.js
@@ -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') {

This comment has been minimized.

@jasnell

jasnell Jan 6, 2017

Member

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

@jasnell

jasnell Jan 6, 2017

Member

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

This comment has been minimized.

@mscdex

mscdex Jan 6, 2017

Contributor

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.

@mscdex

mscdex Jan 6, 2017

Contributor

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.

This comment has been minimized.

@jasnell

jasnell Jan 6, 2017

Member

Good point... hmmm... yeah, there may not be a way around making this a semver-major

@jasnell

jasnell Jan 6, 2017

Member

Good point... hmmm... yeah, there may not be a way around making this a semver-major

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Jan 6, 2017

Member

Changing the message to indicate that a string is required would force it to be semver-major

Member

jasnell commented Jan 6, 2017

Changing the message to indicate that a string is required would force it to be semver-major

@jasnell

jasnell approved these changes Jan 6, 2017

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig Jan 6, 2017

Contributor

I'm going to update the error and make it an uncontroversial semver major.

Contributor

cjihrig commented Jan 6, 2017

I'm going to update the error and make it an uncontroversial semver major.

@cjihrig cjihrig added the semver-major label Jan 6, 2017

@targos

targos approved these changes Jan 6, 2017

Show outdated Hide outdated lib/_http_outgoing.js
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');

This comment has been minimized.

@targos

targos Jan 6, 2017

Member

TypeError

@targos

targos Jan 6, 2017

Member

TypeError

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Jan 6, 2017

Member

A new/updated test may be worthwhile also

Member

jasnell commented Jan 6, 2017

A new/updated test may be worthwhile also

@lpinca

lpinca approved these changes Jan 8, 2017

@cjihrig cjihrig changed the title from lib: remove pointless uses of arguments to http: remove pointless uses of arguments Jan 10, 2017

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig Jan 10, 2017

Contributor

The changes to lib/fs.js are gone since 3c2a936 landed.

Pushed another commit that updates the relevant test @jasnell.

Contributor

cjihrig commented Jan 10, 2017

The changes to lib/fs.js are gone since 3c2a936 landed.

Pushed another commit that updates the relevant test @jasnell.

@cjihrig

This comment has been minimized.

Show comment
Hide comment

cjihrig added some commits Jan 10, 2017

http: remove pointless use of arguments
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>
test: refactor test-http-mutable-headers.js
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>

@cjihrig cjihrig merged commit 2d2a059 into nodejs:master Jan 10, 2017

@cjihrig cjihrig deleted the cjihrig:arguments branch Jan 10, 2017

italoacasas added a commit to italoacasas/node that referenced this pull request Jan 18, 2017

http: remove pointless use of arguments
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>

italoacasas added a commit to italoacasas/node that referenced this pull request Jan 18, 2017

test: refactor test-http-mutable-headers.js
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>

targos added a commit that referenced this pull request Jan 28, 2017

test: refactor test-http-mutable-headers.js
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>

italoacasas added a commit to italoacasas/node that referenced this pull request Jan 30, 2017

test: refactor test-http-mutable-headers.js
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>

italoacasas added a commit to italoacasas/node that referenced this pull request Jan 30, 2017

test: refactor test-http-mutable-headers.js
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>

@italoacasas italoacasas referenced this pull request Jan 31, 2017

Merged

v7.5.0 proposal #11062

@jasnell jasnell referenced this pull request Apr 4, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment