Method: Fuzz.handle_object

Defined in:
lib/fuzz/fuzz.rb

.handle_object(object) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/fuzz/fuzz.rb', line 312

def self.handle_object(object)
  log_verbose(%Q{Handling #{object}})
  fzzrs = select_fzzrs(object)
  no_fixes_allowed = false
  rc = fzzrs.inject(true) do |result, fzzr|
    log_verbose(%Q{+ Running fuzzer #{fzzr.fuzz_id}})
    begin
      if fzzr.run(object, options.apply_fix)
        result
      else
        log_verbose(%Q{+ Error from fuzzer #{fzzr.fuzz_id}})
        false
      end
    rescue
      log_error(%Q{EXCEPTION CAUGHT running fuzzer #{fzzr.fuzz_id} on #{object} - #{$!}\n#{$!.backtrace.join("\n")}})
      no_fixes_allowed = true
      break ## immediately stop handling this object, rc will remain false
    end
  end
  unless no_fixes_allowed
    if Fuzz.apply_fix? && object.changed?
      rc = update_file_object(object) && rc
    end
  end
  rc ? true : false
end