Sha256: b20e6d3cf0c558b1bf6995236e22a1454b05b069a7be8cc38e4fdcbb59ad2f40

Contents?: true

Size: 725 Bytes

Versions: 11

Compression:

Stored size: 725 Bytes

Contents

module RuboCop
  module Cop
    module Ezcater
      class RailsConfiguration < Cop
        MSG = "Use `Rails.configuration` instead of `Rails.application.config`.".freeze
        RAILS_CONFIGURATION = "Rails.configuration".freeze

        def_node_matcher "rails_application_config", <<-PATTERN
          (send (send (const _ :Rails) :application) :config)
        PATTERN

        def on_send(node)
          rails_application_config(node) do
            add_offense(node, location: :expression, message: MSG)
          end
        end

        def autocorrect(node)
          lambda do |corrector|
            corrector.replace(node.source_range, RAILS_CONFIGURATION)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ezcater_rubocop-0.52.6 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.5 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.4 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.3 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.2 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.1 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.0 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.52.0.rc0 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.51.8 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.51.7 lib/rubocop/cop/ezcater/rails_configuration.rb
ezcater_rubocop-0.51.6 lib/rubocop/cop/ezcater/rails_configuration.rb