Sha256: 0d988799cfb137bd0465ea21da10e976f71c21a22353b93143025651f57d2908

Contents?: true

Size: 949 Bytes

Versions: 11

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Discourse
      # Use `type: :multisite` example setting instead of modifying `Rails.configuration.multisite`.
      #
      # @example
      #   # bad
      #   it "works" do
      #     Rails.configuration.multisite = true
      #     do_something
      #   end
      #
      #   # good
      #   it "works", type: :multisite do
      #     do_something
      #   end
      class NoDirectMultisiteManipulation < Cop
        MSG =
          "Use `type: :multisite` example setting instead of modifying `Rails.configuration.multisite`."

        def_node_matcher :multisite_setter?, <<-MATCHER
          (send
            (send
              (const nil? :Rails) :configuration) :multisite=
            _)
        MATCHER

        def on_send(node)
          return unless multisite_setter?(node)

          add_offense(node, message: MSG)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rubocop-discourse-3.8.1 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.7.1 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.7.0 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.6.1 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.6.0 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.5.1 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.5.0 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.4.1 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.4.0 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.3.0 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
rubocop-discourse-3.2.0 lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb