Sha256: 0f21b1ce0a780d2d2d8870be39aa8be3bbfff800ad3355b4185c8795e80a045e
Contents?: true
Size: 980 Bytes
Versions: 7
Compression:
Stored size: 980 Bytes
Contents
# frozen_string_literal: true module RailsBestPractices module Prepares # Check all initializers class InitializerPrepare < Core::Check interesting_nodes :method_add_arg, :class interesting_files INITIALIZER_FILES def initialize @configs = Prepares.configs end # check if AR include ActiveModel::ForbiddenAttributesProtection add_callback :start_method_add_arg do |node| if include_forbidden_attributes_protection?(node) @configs['railsbp.include_forbidden_attributes_protection'] = 'true' end end # check if the node is # ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection) def include_forbidden_attributes_protection?(node) node.receiver.to_s == 'ActiveRecord::Base' && node.message.to_s == 'send' && node.arguments.all.map(&:to_s) == ['include', 'ActiveModel::ForbiddenAttributesProtection'] end end end end
Version data entries
7 entries across 7 versions & 1 rubygems