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

Rails/ActiveRecordCallbacksOrder autocorrect infinite loops if lines contain comments #371

Closed
ghiculescu opened this issue Oct 13, 2020 · 0 comments · Fixed by #373
Closed

Comments

@ghiculescu
Copy link
Contributor

Given this file:

# app/models/foo.rb
class Foo < ApplicationRecord
  after_create :thing1
  before_validation :thing2 # comment
  after_create :thing3 # comment 2
  before_validation :thing4
end

Running rubocop -a hangs forever. If you interrupt it, the file will look something like this:

image

If you remove the comments, it autocorrects fine:

class Foo < ApplicationRecord
  before_validation :thing2
  before_validation :thing4
  after_create :thing1
  after_create :thing3
end

Expected behavior

No infinite loop.

Actual behavior

See above.

Steps to reproduce the problem

See above.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

$ [bundle exec] rubocop -V
0.91.1 (using Parser 2.7.1.4, rubocop-ast 0.4.2, running on ruby 2.7.1 x86_64-darwin19)
rubocop-rails (2.8.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant