Class: RuboCop::Cop::Rails::ApplicationController

Inherits:
RuboCop::Cop
  • Object
show all
Includes:
EnforceSuperclass
Defined in:
lib/rubocop/cop/rails/application_controller.rb

Overview

This cop checks that controllers subclass ApplicationController.

Examples:


# good
class MyController < ApplicationController
  # ...
end

# bad
class MyController < ActionController::Base
  # ...
end

Constant Summary collapse

MSG =
'Controllers should subclass `ApplicationController`.'
SUPERCLASS =
'ApplicationController'
BASE_PATTERN =
'(const (const nil? :ActionController) :Base)'

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object

rubocop:enable Layout/ClassStructure



28
29
30
31
32
# File 'lib/rubocop/cop/rails/application_controller.rb', line 28

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