-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add new Style/NonLocalControlFlowInTernary cop #7406
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
Add new Style/NonLocalControlFlowInTernary cop #7406
Conversation
This will also need an entry in the style guide. |
What if control flow exists on both sides of the ternary? Should it still be flagged? |
👍 Will add when I have some time.
Yes. I should add a test case for that. 🙂 |
@Drenmi ping :-) |
It may not be a problem when limited to ternary operator. |
618ef96
to
c0a54e8
Compare
@koic @bbatsov I have rebased this and added the spec that @rrosenblum suggested. I think we can merge this. I suspect the Style Guide PR will take some time to iron out. 🙂 |
Style/NonLocalControlFlowInTernary: | ||
Description: 'checks for non-local control flow in ternary expressions.' | ||
Enabled: true | ||
VersionAdded: '0.76' |
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.
It looks like the version needs to be updated.
VersionAdded: '0.76' | |
VersionAdded: '0.81' |
@@ -0,0 +1,46 @@ | |||
# frozen_string_literal: true | |||
|
|||
# TODO: when finished, run `rake generate_cops_documentation` to update the docs |
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.
Can you remove the auto-generated line?
I'm closing this PR due to no recent activity. Feel free to re-open it if you ever come back to it. |
This cop checks for non-local control flow, i.e.
return
,break
,next
,raise
, etc. used in ternary expressions.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.