Sha256: 6f7a82b1b05e8ccdbf0c807d7b789d36515cd415d3660788ce9adf97e45c7eae
Contents?: true
Size: 972 Bytes
Versions: 4
Compression:
Stored size: 972 Bytes
Contents
require 'simplabs/excellent/checks/base' module Simplabs module Excellent module Checks module Rails # This check reports +ActiveRecord+ models that define a custom +initialize+ method. Since +ActiveRecord+ does not always call +new+ to # create instances, these custom +initialize+ methods might not always be called, which makes the behavior of the application very hard to # understand. # # ==== Applies to # # * +ActiveRecord+ models class CustomInitializeMethodCheck < Base def initialize(options = {}) #:nodoc: super @interesting_contexts = [Parsing::ClassContext] end def evaluate(context) #:nodoc: add_warning(context, '{{class}} defines initialize method.', { :class => context.full_name }) if context.active_record_model? && context.defines_initializer? end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems