class RuboCop::AST::Node
def pure?
So, is evaluation of this node free of side effects?
expressions which are equivalent in value.
number of times they are evaluated, or replace them with other
and have no side effects, that means we can reorder them, change the
If we know that expressions are useful only for their return values,
effects, and some for both.
Some expressions are evaluated for their value, some for their side
def pure? # Be conservative and return false if we're not sure case type when :__FILE__, :__LINE__, :const, :cvar, :defined?, :false, :float, :gvar, :int, :ivar, :lvar, :nil, :str, :sym, :true, :regopt true when :and, :array, :begin, :case, :dstr, :dsym, :eflipflop, :ensure, :erange, :for, :hash, :if, :iflipflop, :irange, :kwbegin, :not, :or, :pair, :regexp, :until, :until_post, :when, :while, :while_post child_nodes.all?(&:pure?) else false end end