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

Cop idea: ActiveSupport's skip_callback/set_callback with (explicit) constant receiver #65

Open
viralpraxis opened this issue Nov 26, 2024 · 0 comments

Comments

@viralpraxis
Copy link
Collaborator

I've seen code like this (in test suites):

around do |example|
  Site.skip_callback(:commit, :after, :after_owner_change)

  example.run
ensure
  Site.set_callback(:commit, :after, :after_owner_change, if: :saved_change_to_owner?)
end

And it might lead to thread-safety problems due to it's process-wide effect. I remember it was once related to ActiveJob's async adapter which uses thread pool under the hood.

This cop should not warn about class User < ApplicationRecord; skip_callback :commit, :after, :after_owner_change; end

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

1 participant