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

[Fix #10592] Fix infinite loop on Style/MultilineTernaryOperator #10594

Conversation

nobuyo
Copy link
Contributor

@nobuyo nobuyo commented Apr 30, 2022

…if using assignment method and condition/branch is multiline.

Fixes #10592.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@nobuyo nobuyo marked this pull request as draft April 30, 2022 15:20
@nobuyo
Copy link
Contributor Author

nobuyo commented Apr 30, 2022

This doesn't solve the case of other assignment-based methods...

class Test
  def value=(value)
    @value = value
  end
end

test = Test.new
test.value = a ==
  b ? c : d

@nobuyo nobuyo force-pushed the fix-infinite-loop-on-style-multiline-ternary-operator branch 2 times, most recently from cdfc218 to d5f4105 Compare April 30, 2022 15:35
@nobuyo
Copy link
Contributor Author

nobuyo commented Apr 30, 2022

All assignment methods are now supported by d5f4105be2298805eb204beb08ae9155abc8ce19.

@nobuyo nobuyo marked this pull request as ready for review April 30, 2022 15:42
…tor` if using assignment method and condition/branch is multiline

Update lib/rubocop/cop/style/multiline_ternary_operator.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
@nobuyo nobuyo force-pushed the fix-infinite-loop-on-style-multiline-ternary-operator branch from 520faf6 to 153b651 Compare April 30, 2022 15:45
@koic koic merged commit 44491fb into rubocop:master Apr 30, 2022
@koic
Copy link
Member

koic commented Apr 30, 2022

Thanks! Incidentally, for some reason your PRs don't trigger CircleCI. If you like, please contact CircleCI :-)

@nobuyo
Copy link
Contributor Author

nobuyo commented Apr 30, 2022

Thank you, I will give it a try. I was actually just wondering why CircleCI wouldn't start only my PR 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Style/MultilineTernaryOperator may create infinite loop
2 participants