Skip to content
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

child_process: charify the usage of 'else' #11148

Closed
wants to merge 1 commit into from

Conversation

JacksonTian
Copy link
Contributor

@JacksonTian JacksonTian commented Feb 3, 2017

the keyword 'else' is unnecessary after 'throw' statements.

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

child_process

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Feb 3, 2017

if (killSignal === 0)
throw new RangeError('"killSignal" cannot be 0');
} else if (killSignal != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to the != null check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, the killSignal can be false, undefined.

@lpinca
Copy link
Member

lpinca commented Feb 3, 2017

@JacksonTian there is a small typo in the commit message (it can be fixed when landed).

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave the throw err; statements on their own separate lines.

@petercunha
Copy link

What is the point of this

@mscdex
Copy link
Contributor

mscdex commented Feb 3, 2017

@petercunha The else branch in these code blocks are technically unnecessary because execution will not continue if the if branch is taken.

@mscdex
Copy link
Contributor

mscdex commented Feb 3, 2017

Also, I noticed the typo in the commit message as well. Please remember to fix it now or on landing.

@petercunha
Copy link

@mscdex I understand that, it just seems entirely unnecessary.

@Trott
Copy link
Member

Trott commented Feb 5, 2017

No opinion on this one, but if we are going to do it, might as well get the else on line 38 too?

@JacksonTian
Copy link
Contributor Author

Hi @Trott I see the PR #11159 add no-else-return ESLint rule. Let the PR cover this PR?

@Trott
Copy link
Member

Trott commented Feb 6, 2017

Hi @Trott I see the PR #11159 add no-else-return ESLint rule. Let the PR cover this PR?

That PR and that ESLint rule only cover this situation with return but not throw. So I'd keep this PR and that PR separate.

@JacksonTian
Copy link
Contributor Author

Ok. Let me fix line 38 too.

the keyword 'else' is unnecessary after 'throw' statements.
}

options = util._extend({}, arguments[pos++]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means we access an out-of-bounds pos on arguments, which recent PRs have claimed is a deoptimization. Any concern with that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #10323 for more context on my comment above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's actually a potentially out of bounds check immediately above. I'd recommend going through in a separate PR and dealing with those.

@jasnell
Copy link
Member

jasnell commented Feb 17, 2017

@fhinkel
Copy link
Member

fhinkel commented Mar 26, 2017

Thanks. Landed in dc9717c.

@fhinkel fhinkel closed this Mar 26, 2017
fhinkel pushed a commit that referenced this pull request Mar 26, 2017
The keyword 'else' is unnecessary after 'throw' statements.

PR-URL: #11148
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 28, 2017
The keyword 'else' is unnecessary after 'throw' statements.

PR-URL: #11148
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
@MylesBorins
Copy link
Contributor

This does not land cleanly in LTS. Please feel free to manually backport. Please also feel free to replace the backport request label with do-not-land if it shouldn't land

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.