Sha256: d4eb850545cbaed604db9f17b33dc7690f8125c799776e852f2e72ca5d3afd6d
Contents?: true
Size: 835 Bytes
Versions: 4
Compression:
Stored size: 835 Bytes
Contents
require 'simplabs/excellent/checks/base' module Simplabs module Excellent module Checks # This check reports conditionals that test an assignment as in # # something(var) if var = method() # # Assignments in conditions are often typos. # # ==== Applies to # # * +if+ # * +else+ # * +while+ # * +until+ class AssignmentInConditionalCheck < Base def initialize(options = {}) #:nodoc: super @interesting_contexts = [Parsing::IfContext, Parsing::WhileContext, Parsing::UntilContext] @interesting_files = [/\.rb$/, /\.erb$/] end def evaluate(context) #:nodoc: add_warning(context, 'Assignment in condition.') if context.tests_assignment? end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems