Sha256: 96e1bc3ec4c1debc4dbdfb05d6813a8df449e2a87551e36db4f0c80489c78f58

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rails
      # This cop checks that models subclass ApplicationRecord with Rails 5.0.
      #
      # @example
      #
      #  # good
      #  class Rails5Model < ApplicationRecord
      #    ...
      #  end
      #
      #  # bad
      #  class Rails4Model < ActiveRecord::Base
      #    ...
      #  end
      class ApplicationRecord < Cop
        extend TargetRailsVersion

        minimum_target_rails_version 5.0

        MSG = 'Models should subclass `ApplicationRecord`.'.freeze
        SUPERCLASS = 'ApplicationRecord'.freeze
        BASE_PATTERN = '(const (const nil :ActiveRecord) :Base)'.freeze

        include RuboCop::Cop::EnforceSuperclass
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.50.0 lib/rubocop/cop/rails/application_record.rb
rubocop-0.49.1 lib/rubocop/cop/rails/application_record.rb
rubocop-0.49.0 lib/rubocop/cop/rails/application_record.rb