Sha256: c37d4fcfcda827c6816264a9f9ccff70bf1057fc1934081daeed3fb8a3e15d0c
Contents?: true
Size: 786 Bytes
Versions: 8
Compression:
Stored size: 786 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_nodes = [:if, :while, :until] @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
8 entries across 8 versions & 2 rubygems