Sha256: b510c39d56de82cfce35923c4120f7612e91850f155091c9f0ce509e8d571a19
Contents?: true
Size: 643 Bytes
Versions: 3
Compression:
Stored size: 643 Bytes
Contents
require 'roodi/checks/check' module Roodi module Checks class AssignmentInConditionalCheck < Check def initialize(options = {}) super() end def interesting_nodes [:if, :while, :until] end def evaluate(node) add_error if has_assignment?(node[1]) end private def has_assignment?(node) found_assignment = false found_assignment = found_assignment || node.node_type == :lasgn node.children.each { |child| found_assignment = found_assignment || has_assignment?(child) } found_assignment end end end end
Version data entries
3 entries across 3 versions & 1 rubygems