Sha256: c94f888f7b0488053cc1ab4e3fca49f45b2ba573dea03569e0f75d9801f06086

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Rails
      # This cop checks for the use of old-style attribute validation macros.
      class Validation < Cop
        MSG = 'Use the new "sexy" validations (validates ...).'

        BLACKLIST = [:validates_acceptance_of,
                     :validates_confirmation_of,
                     :validates_exclusion_of,
                     :validates_format_of,
                     :validates_inclusion_of,
                     :validates_length_of,
                     :validates_numericality_of,
                     :validates_presence_of,
                     :validates_size_of]

        def on_send(node)
          receiver, method_name, *_args = *node

          if receiver.nil? && BLACKLIST.include?(method_name)
            add_offence(:convention, node.loc.selector, MSG)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/rails/validation.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/rails/validation.rb