class RuboCop::Runner
def iterate_until_no_changes(source, offenses_by_iteration)
def iterate_until_no_changes(source, offenses_by_iteration) # Keep track of the state of the source. If a cop modifies the source # and another cop undoes it producing identical source we have an # infinite loop. @processed_sources = [] # It is also possible for a cop to keep adding indefinitely to a file, # making it bigger and bigger. If the inspection loop runs for an # excessively high number of iterations, this is likely happening. iterations = 0 loop do check_for_infinite_loop(source, offenses_by_iteration) if (iterations += 1) > MAX_ITERATIONS raise InfiniteCorrectionLoop.new(source.path, offenses_by_iteration) end source = yield break unless source end end