Class: Nitpick::BranchNitpicker

Inherits:
Nitpicker
  • Object
show all
Defined in:
lib/nitpick/branch_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
13
14
15
# File 'lib/nitpick/branch_nitpicker.rb', line 3

def process_if(exp)
  cond = process(exp.shift)
  yes_branch = process(exp.shift)
  no_branch = process(exp.shift)
  
  scan_for [Warnings::UselessBranch, Warnings::IdenticalBranch],
       :with => [cond, yes_branch, no_branch]
  
  scan_for [Warnings::AssignmentAsCondition],
       :with => [cond]
  
  s(:if, cond, yes_branch, no_branch)
end