Sha256: 593828f19a69d880433c6b27f3dfb942fd88a447444bb4e463f97d75406f1da2

Contents?: true

Size: 944 Bytes

Versions: 11

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rails
      # This cop checks that controllers subclass ApplicationController.
      #
      # @example
      #
      #  # good
      #  class MyController < ApplicationController
      #    # ...
      #  end
      #
      #  # bad
      #  class MyController < ActionController::Base
      #    # ...
      #  end
      class ApplicationController < Cop
        MSG = 'Controllers should subclass `ApplicationController`.'
        SUPERCLASS = 'ApplicationController'
        BASE_PATTERN = '(const (const nil? :ActionController) :Base)'

        # rubocop:disable Layout/ClassStructure
        include RuboCop::Cop::EnforceSuperclass
        # rubocop:enable Layout/ClassStructure

        def autocorrect(node)
          lambda do |corrector|
            corrector.replace(node.source_range, self.class::SUPERCLASS)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rubocop-rails-2.8.1 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.8.0 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.7.1 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.7.0 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.6.0 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.5.2 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.5.1 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.5.0 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.4.2 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.4.1 lib/rubocop/cop/rails/application_controller.rb
rubocop-rails-2.4.0 lib/rubocop/cop/rails/application_controller.rb