Sha256: 2729c1b4e90ce2d4f9df5d6116caca67c409dd55367005258971b593c0284827

Contents?: true

Size: 871 Bytes

Versions: 10

Compression:

Stored size: 871 Bytes

Contents

require 'processors/lib/find_call'

#This processor specifically looks for calls like
# User.active.human.find(:all, :conditions => ...)
class FindModelCall < FindCall

  #Passes +targets+ to FindCall
  def initialize targets
    super(targets, /^(find.*|first|last|all)$/)
  end 

  #Matches entire method chain as a target. This differs from
  #FindCall#get_target, which only matches the first expression in the chain.
  def get_target exp
    if sexp? exp
      case exp.node_type
      when :ivar, :lvar, :const
        exp[1]
      when :true, :false
        exp[0]
      when :lit
        exp[1]
      when :colon2
        class_name exp
      when :call
        t = get_target(exp[1])
        if t and match(@find_targets, t)
          t
        else
          process exp
        end
      else
        process exp
      end
    else
      exp
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
brakeman-min-0.2.2 lib/processors/lib/find_model_call.rb
brakeman-0.2.2 lib/processors/lib/find_model_call.rb
brakeman-min-0.2.1 lib/processors/lib/find_model_call.rb
brakeman-0.2.1 lib/processors/lib/find_model_call.rb
brakeman-min-0.2.0 lib/processors/lib/find_model_call.rb
brakeman-0.2.0 lib/processors/lib/find_model_call.rb
brakeman-0.1.1 lib/processors/lib/find_model_call.rb
brakeman-0.1.0 lib/processors/lib/find_model_call.rb
brakeman-0.0.3 lib/processors/lib/find_model_call.rb
brakeman-0.0.2 lib/processors/lib/find_model_call.rb