Class: Scanny::Checks::BeforeFiltersCheck
- Defined in:
- lib/scanny/checks/before_filters_check.rb
Overview
Checks for use of the “before_filter” method with certain filters.
Constant Summary collapse
- FILTERS =
[:login_required, :admin_required]
Instance Method Summary collapse
- #check(node) ⇒ Object
-
#pattern ⇒ Object
before_filter :login_required.
Methods inherited from Check
#compiled_pattern, #issue, #strict?, #visit
Instance Method Details
#check(node) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/scanny/checks/before_filters_check.rb', line 24 def check(node) filter_node = node.arguments.array.find do |argument| argument.is_a?(Rubinius::AST::SymbolLiteral) && FILTERS.include?(argument.value) end issue :info, "The \"before_filter\" method with :#{filter_node.value} filter is used." end |
#pattern ⇒ Object
before_filter :login_required
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/scanny/checks/before_filters_check.rb', line 8 def pattern <<-EOT SendWithArguments< receiver = Self, name = :before_filter, arguments = ActualArguments< array = [ any*, SymbolLiteral<value = #{FILTERS.map(&:inspect).join(' | ')}>, any* ] > > EOT end |