Sha256: 8a893a72c5846df016f95b33cfcc7ea382b78e47bc8986039f53de2c7ede6ac6
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 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 #: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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
excellent-1.7.2 | lib/simplabs/excellent/checks/rails/custom_initialize_method_check.rb |