fix: accurate issue creation date backdating via SCM changesets#129
Conversation
SummaryComplete rewrite of issue backdating logic, shifting from arbitrary date-bucket assignment to preserving original SonarQube creation dates. The old approach grouped files into ≤5K-issue batches and assigned sequential dates 30 days apart—spreading issues across multiple SonarCloud date buckets but losing accuracy. The new approach maps each issue's creation date directly to its line range in the SCM changeset, leveraging SonarCloud's CE behavior of taking MAX(date) across an issue's textRange. Three-phase process: safety split for calendar days >5K issues (pre-assigns synthetic 1-day-spaced dates to sub-batches), per-line date mapping with "oldest wins" collision handling, and changeset rebuild with one entry per unique date per file. Files changed: core rewrite of What reviewers should knowStart here:
Key things to verify:
Non-obvious decisions:
Migration test checklist from logs:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 43c89a8. Configure here.
| for (let batchIdx = 0; batchIdx < totalBatches - 1; batchIdx++) { | ||
| const syntheticDate = group.dateMs - (totalBatches - 1 - batchIdx) * ONE_DAY_MS; | ||
| for (const issue of subBatches[batchIdx]) { | ||
| effectiveDates.set(issue.key, syntheticDate); |
There was a problem hiding this comment.
Safety split synthetic dates may collide with existing days
Low Severity
The safety split pushes synthetic dates backward by (totalBatches - 1 - batchIdx) * ONE_DAY_MS from the original day. These synthetic dates can land on calendar days that already have issues — including days that themselves triggered a safety split. When multiple adjacent days each exceed 5K issues, their backward-shifted synthetic dates can accumulate on the same target day, potentially exceeding the 10K ES visualization cap that the safety split aims to prevent.
Reviewed by Cursor Bugbot for commit 43c89a8. Configure here.
|
The migration is I/O-bound (API calls to SonarCloud at ~5 issues/sec). |


Summary
backdateChangesets()to preserve each issue's original SonarQube creation date in SonarCloud, replacing the previous arbitrary 30-day-spaced bucket approachcreationDateis mapped to per-line SCM blame dates in the changeset protobuf. The CE takes MAX(date) across an issue's textRange, so "oldest wins" for overlapping lines preserves accurate datesAlgorithm (3 phases)
Files changed
src/shared/utils/batch-distributor/helpers/backdate-changesets.js— complete rewritedocs/— CHANGELOG, architecture, bespoke-algorithms, technical-details, troubleshooting, key-capabilities updatedTest plan
npm run packagebuilds successfully🤖 Generated with Claude Code
Note
Medium Risk
Changes core SCM changeset rewriting logic that influences SonarCloud issue creation dates; mistakes could skew dates or trigger ES bucket caps on large migrations.
Overview
Replaces the prior file/batch-level SCM date bucketing with per-issue creation-date preservation.
backdateChangesets()is rewritten to map each issue’s SonarQubecreationDateonto itstextRangelines, rebuild per-filechangesets[]with one entry per unique date, and setchangesetIndexByLine[]accordingly (defaulting non-issue lines to the oldest date).Adds a safety-split for days exceeding
ISSUE_BATCH_SIZE(5K) by assigning 1-day-spaced synthetic dates without splitting files, and updates logging to report unique/top dates by line count. Documentation acrossdocs/is refreshed to describe the new backdating approach and deprecate the old 30-day bucket strategy.Reviewed by Cursor Bugbot for commit 43c89a8. Bugbot is set up for automated code reviews on this repo. Configure here.