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

InfiniteCorrectionLoop when auto-correcting constant assignment with implicit array #3170

Closed
grosser opened this issue May 27, 2016 · 2 comments

Comments

@grosser
Copy link
Contributor

grosser commented May 27, 2016

code

XXX = YYY, ZZZ

result

XXX = YYY, ZZZ.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze.freeze ....

expected result

either do not correct or wrap in array and then add freeze

backtrace

vendor/bundle/ruby/2.1.0/gems/rubocop-0.40.0/lib/rubocop/runner.rb:169:in `block in do_inspection_loop'
vendor/bundle/ruby/2.1.0/gems/rubocop-0.40.0/lib/rubocop/runner.rb:165:in `loop'
vendor/bundle/ruby/2.1.0/gems/rubocop-0.40.0/lib/rubocop/runner.rb:165:in `do_inspection_loop'
vendor/bundle/ruby/2.1.0/gems/rubocop-0.40.0/lib/rubocop/runner.rb:87:in `process_file'

version

0.40.0 (using Parser 2.3.1.0, running on ruby 2.1.8 x86_64-darwin14.0)

@alexdowad
Copy link
Contributor

...Just passed through and discovered that 122 open issues have accumulated! Youch!

@grosser
Copy link
Contributor Author

grosser commented May 30, 2016

just close 23 and we are back under 100 ;)

On Mon, May 30, 2016 at 7:12 AM, Alex Dowad [email protected]
wrote:

...Just passed through and discovered that 122 open issues have
accumulated! Youch!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#3170 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAsZ6XB3kZbTmjFODjQBR_L4BVOSYkJks5qGvBbgaJpZM4IoEtb
.

@bbatsov bbatsov closed this as completed in 73f7a0e Jun 6, 2016
akhramov pushed a commit to akhramov/rubocop that referenced this issue Sep 1, 2017
`Style/ConditionalAssignment` cop's autocorrection results in invalid
syntax when it encounters assignment to unbracketed array.

This commit modifies ConditionalAssignment cop's autocorrection so, it
wraps array in brackets, if needed.
This issue is very simillar to rubocop#3170, where `Style/MutableConstant`
wasn't able to properly handle assignment to unbracketed array.
Since both `MutableConstant` and `ConditionalAssignment` cops need to
check whether array node is bracketed or not, new method
`Rubocop::AST::ArrayNode#bracketed?` was introduced, to avoid
duplication.
bbatsov pushed a commit that referenced this issue Sep 4, 2017
`Style/ConditionalAssignment` cop's autocorrection results in invalid
syntax when it encounters assignment to unbracketed array.

This commit modifies ConditionalAssignment cop's autocorrection so, it
wraps array in brackets, if needed.
This issue is very simillar to #3170, where `Style/MutableConstant`
wasn't able to properly handle assignment to unbracketed array.
Since both `MutableConstant` and `ConditionalAssignment` cops need to
check whether array node is bracketed or not, new method
`Rubocop::AST::ArrayNode#bracketed?` was introduced, to avoid
duplication.
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

No branches or pull requests

2 participants