Sha256: 4c6957f8283e3ebdd8516ec6bfd660318404604b67e113f974f969092c8ee8ce

Contents?: true

Size: 760 Bytes

Versions: 8

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

require "rubocop"

module RuboCop
  module Cop
    module AnyCable
      # Checks for remote disconnect usage.
      #
      # @example
      #   # bad
      #   class MyServive
      #     def call(user)
      #       ActionCable.server.remote_connections.where(current_user: user).disconnect
      #     end
      #   end
      #
      class RemoteDisconnect < RuboCop::Cop::Cop
        MSG = "Disconnecting remote clients is not supported in AnyCable"

        def_node_matcher :has_remote_disconnect?, <<-PATTERN
          (send (send (send _ :remote_connections) ...) :disconnect)
        PATTERN

        def on_send(node)
          add_offense(node) if has_remote_disconnect?(node)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
anycable-rails-1.0.0.preview2 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-1.0.0.preview1 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-0.6.5 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-0.6.4 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-0.6.3 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-0.6.2 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-0.6.1 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
anycable-rails-0.6.0.rc1 lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb