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

Add new Rails/ActiveRecordCallbacksOrder cop #285

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

fatkodima
Copy link
Contributor

https://rails.rubystyle.guide/#callbacks-order

I always wanted to have a similar cop, and here it is 😄

@fatkodima fatkodima force-pushed the active-record-callbacks-order-cop branch from 1328643 to b703739 Compare June 30, 2020 18:47
config/default.yml Outdated Show resolved Hide resolved
@fatkodima fatkodima force-pushed the active-record-callbacks-order-cop branch from b703739 to 4501b02 Compare July 1, 2020 09:15
@koic
Copy link
Member

koic commented Jul 14, 2020

The current implementation produces the following error.

class User < ApplicationRecord
  def do_something
  end
end
     NoMethodError:
       undefined method `send_type?' for :do_something:Symbol
     # ./lib/rubocop/cop/rails/active_record_callbacks_order.rb:97:in `callback?'
     # ./lib/rubocop/cop/rails/active_record_callbacks_order.rb:90:in `block in defined_callbacks'
     # ./lib/rubocop/cop/rails/active_record_callbacks_order.rb:90:in `select'
     # ./lib/rubocop/cop/rails/active_record_callbacks_order.rb:90:in `defined_callbacks'
     # ./lib/rubocop/cop/rails/active_record_callbacks_order.rb:55:in `on_class'

@fatkodima fatkodima force-pushed the active-record-callbacks-order-cop branch from 4501b02 to 8335f41 Compare July 14, 2020 10:24
@fatkodima
Copy link
Contributor Author

fatkodima commented Jul 14, 2020

Updated. Added a test case for failing example.

@koic koic merged commit 9043417 into rubocop:master Jul 14, 2020
@koic
Copy link
Member

koic commented Jul 14, 2020

Thanks!

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.

3 participants