Closed sobakasu closed 2 years ago
There is infinite recursion when applying autocorrections for the Style/CollectionMethods cop.
Style/CollectionMethods
For example, the following code:
next unless (entry = version.entries.find { |e| e.id.to_s == error["id"].to_s })
produces this error:
Offenses: app/controllers/timesheets/employees_controller.rb:176:48: C: [Corrected] Style/CollectionMethods: Prefer detect over find. next unless (entry = version.entries.find { |e| e.id.to_s == error["id"].to_s }) ^^^^ app/controllers/timesheets/employees_controller.rb:176:48: C: [Corrected] Style/CollectionMethods: Prefer find over detect. next unless (entry = version.entries.detect { |e| e.id.to_s == error["id"].to_s }) ^^^^^^ app/controllers/timesheets/employees_controller.rb:189:46: C: [Corrected] Style/CollectionMethods: Prefer detect over find. next unless (entry = version.entries.find { |e| e.id.to_s == entry_id.to_s }) ^^^^ app/controllers/timesheets/employees_controller.rb:189:46: C: [Corrected] Style/CollectionMethods: Prefer find over detect. next unless (entry = version.entries.detect { |e| e.id.to_s == entry_id.to_s }) ^^^^^^ 113 files inspected, 4 offenses detected, 4 offenses corrected Infinite loop detected in /Users/andy/work/gus/app/controllers/timesheets/employees_controller.rb and caused by Style/CollectionMethods -> Style/CollectionMethods /Users/andy/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/rubocop-1.28.2/lib/rubocop/runner.rb:296:in `check_for_infinite_loop' /Users/andy/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/rubocop-1.28.2/lib/rubocop/runner.rb:279:in `block in iterate_until_no_changes'
This issue can be worked around by adding the following to .rubocop.yml or .rubocop-todo.yml:
Style/CollectionMethods: Enabled: false
@sobakasu is this still an issue with 1.0.0? Happy to have your change applied if so.
There is infinite recursion when applying autocorrections for the
Style/CollectionMethods
cop.For example, the following code:
produces this error:
This issue can be worked around by adding the following to .rubocop.yml or .rubocop-todo.yml: