Sha256: e9079c9f5779f097c3b0747041ae292be3cb7b9adafb49aad43c56df3613854f

Contents?: true

Size: 873 Bytes

Versions: 10

Compression:

Stored size: 873 Bytes

Contents

module RuboCop
  module Cop
    module Salsify
      # Check that mailers subclass ApplicationMailer with Rails 5.0.
      #
      # @example
      #
      #  # good
      #  class Tesla < ApplicationMailer
      #    ...
      #  end
      #
      #  # bad
      #  class Yugo < ActionMailer::Base
      #    ...
      #  end
      class RailsApplicationMailer < Cop
        extend TargetRailsVersion

        minimum_target_rails_version 5.0

        MSG = 'Mailers should subclass `ApplicationMailer`.'.freeze
        SUPERCLASS = 'ApplicationMailer'.freeze
        BASE_PATTERN = '(const (const nil? :ActionMailer) :Base)'.freeze

        include RuboCop::Cop::EnforceSuperclass

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
salsify_rubocop-0.78.1 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.78.0 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.63.0 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.62.0 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.60.0.1 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.60.0 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.59.2.1.rc1 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.58.0.rc1 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.52.1.1 lib/rubocop/cop/salsify/rails_application_mailer.rb
salsify_rubocop-0.52.1 lib/rubocop/cop/salsify/rails_application_mailer.rb