Skip to content

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

@viralpraxis

Description

@viralpraxis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions