Class: Nitpick::BlockNitpicker

Inherits:
Nitpicker
  • Object
show all
Defined in:
lib/nitpick/block_nitpicker.rb

Instance Attribute Summary

Attributes inherited from Nitpicker

#warnings

Instance Method Summary collapse

Methods inherited from Nitpicker

#initialize, #nitpick!, #process_cfunc, #process_defn, #scan_for, #warn

Constructor Details

This class inherits a constructor from Nitpick::Nitpicker

Instance Method Details

#process_if(exp) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/nitpick/block_nitpicker.rb', line 3

def process_if(exp)
  cond = Sexp.from_array(exp.shift)
  yes_branch = Sexp.from_array(exp.shift)
  no_branch = Sexp.from_array(exp.shift)
  
  scan_for [Warnings::UnprotectedBlock],
       :with => [cond, yes_branch, no_branch]
  
  s(:if, cond, yes_branch, no_branch)
end

#process_yield(exp) ⇒ Object



14
15
16
17
18
19
# File 'lib/nitpick/block_nitpicker.rb', line 14

def process_yield(exp)
  exp.clear
  warn Warnings::UnprotectedBlock.new
  
  s(:yield)
end