Sha256: efe61d1efe8bfcaa9f772c3baa78afb849dc5c00203186e2c2dc5af8e0e3161e

Contents?: true

Size: 855 Bytes

Versions: 5

Compression:

Stored size: 855 Bytes

Contents

#Contains a couple shared methods for Processors.
module Brakeman::ProcessorHelper

  #Sets the current module.
  def process_module exp
    @current_module = class_name(exp[1]).to_s
    process exp[2] 
    @current_module = nil
    exp
  end

  #Returns a class name as a Symbol.
  def class_name exp
    case exp
    when Sexp
      case exp.node_type
      when :const
        exp[1]
      when :lvar
        exp[1].to_sym
      when :colon2
        "#{class_name(exp[1])}::#{exp[2]}".to_sym
      when :colon3
        "::#{exp[1]}".to_sym
      when :call
        process exp
      when :self
        @current_class || @current_module || nil
      else
        raise "Error: Cannot get class name from #{exp}"
      end
    when Symbol
      exp
    when nil
      nil
    else
      raise "Error: Cannot get class name from #{exp}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
brakeman-1.5.2 lib/brakeman/processors/lib/processor_helper.rb
brakeman-1.5.1 lib/brakeman/processors/lib/processor_helper.rb
brakeman-1.5.0 lib/brakeman/processors/lib/processor_helper.rb
brakeman-1.4.0 lib/brakeman/processors/lib/processor_helper.rb
brakeman-1.3.0 lib/brakeman/processors/lib/processor_helper.rb