Class Roodi::Checks::AssignmentInConditionalCheck
In: lib/roodi/checks/assignment_in_conditional_check.rb
Parent: Roodi::Checks::Check

Checks a conditional to see if it contains an assignment.

A conditional containing an assignment is likely to be a mistyped equality check. You should either fix the typo or factor out the assignment so that the code is clearer.

Methods

Public Class methods

[Source]

# File lib/roodi/checks/assignment_in_conditional_check.rb, line 10
      def initialize(options = {})
        super()
      end

Public Instance methods

[Source]

# File lib/roodi/checks/assignment_in_conditional_check.rb, line 18
      def evaluate_start(node)
        add_error("Found = in conditional.  It should probably be an ==") if has_assignment?(node[1])
      end

[Source]

# File lib/roodi/checks/assignment_in_conditional_check.rb, line 14
      def interesting_nodes
        [:if, :while]
      end

[Validate]