scheduleWrite static method

void scheduleWrite()

Schedule report writing after a debounce period.

Each call resets the timer. When no new violations arrive for _debounce duration, the report is written. The same report file is overwritten on each write so it always reflects cumulative data.

Per-file de-duplication is handled by ProgressTracker._clearFileData, so re-analyzed files don't double-count.

When a report has already been written and ProgressTracker detects file re-analysis (a new build/session), this method starts a fresh session: resets trackers, generates a new timestamp, and writes to a new report file.

Implementation

static void scheduleWrite() {
  if (_projectRoot == null) return;

  // Detect new analysis session: a report was already written and the
  // analyzer is now re-visiting files it already processed. This is
  // safe from false positives because late-arriving straggler files are
  // new (wasNew=true) and never set the re-analysis flag.
  if (_hasReportWritten && ProgressTracker.hasReanalyzedFile) {
    _startNewSession();
  }

  _debounceTimer?.cancel();
  _debounceTimer = Timer(_debounce, _writeReport);
}