feat(updaters): add Gradle version catalog TOML updater - #597
Conversation
Reviewer's GuideAdds a new TOML-based Gradle version catalog updater and comprehensive tests/fixtures to support updating dependency versions via centralized refs, inline declarations, and shorthand strings while preserving formatting and comments. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/updaters/toml_updater.js" line_range="238-247" />
<code_context>
+ * @param {string} newVersion - replacement version string
+ * @returns {string} updated content
+ */
+function replaceInlineVersion(content, alias, oldVersion, newVersion) {
+ const escapedAlias = escapeRegExp(alias)
+ const escapedOld = escapeRegExp(oldVersion)
+ const pattern = new RegExp(
+ `^(\\s*${escapedAlias}\\s*=\\s*\\{[^}]*version\\s*=\\s*")${escapedOld}("[^}]*\\}\\s*)$`,
+ 'm'
+ )
+ const result = content.replace(pattern, `$1${newVersion}$2`)
+ if (result !== content) {
+ return result
+ }
+ const stringPattern = new RegExp(
+ `^(\\s*${escapedAlias}\\s*=\\s*"[^:]+:[^:]+:)${escapedOld}("\\s*)$`,
+ 'm'
+ )
+ return content.replace(stringPattern, `$1${newVersion}$2`)
+}
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Handle failure to match inline versions to avoid false positives in `applied`
`replaceInlineVersion` can return the original `content` when neither regex matches (e.g. formatting differences or the version being in a different position), but the caller still records this as applied. Consider detecting when no replacement occurs and propagating that information so the caller can mark the change as skipped instead. For example, return `{ content, replaced: boolean }` or compare the result with the input and act accordingly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #597 +/- ##
==========================================
+ Coverage 90.84% 91.04% +0.20%
==========================================
Files 39 40 +1
Lines 8363 8635 +272
Branches 1453 1501 +48
==========================================
+ Hits 7597 7862 +265
- Misses 766 773 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Verification Report for TC-5412 (commit 8edd65e)
Overall: WARNRuntime Verification (manual)The
Issues Requiring Attention1. 2. Unused 3. This comment was AI-generated by sdlc-workflow/verify-pr v0.13.7. |
Implements TC-5412 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Assisted-by: Claude Code
…ion strings String.prototype.replace() treats $1, $$, $& as special patterns in replacement strings. Switch all three .replace() calls in replaceVersionInSection and replaceInlineVersion to use arrow function replacers, avoiding $ interpretation entirely. Implements TC-5447 Assisted-by: Claude Code
…onInSection The section parameter was declared but never referenced in the function body. Removed from the signature, JSDoc, and the single call site. Implements TC-5448 Assisted-by: Claude Code
Compare content before/after replaceInlineVersion and push to skipped instead of applied when the regex does not match. Prevents false positives in the applied results for entries with formatting the single-line regex cannot handle. Implements TC-5449 Assisted-by: Claude Code
Summary
src/updaters/toml_updater.jsmodule withupdateTomlVersions()APIversion.ref, inlineversion = "x.y.z", and string shorthand patternsgroup/namenotation alongsidemodulenotationImplements TC-5412
Test plan
version.refnpm run lintpassesnpm testpassesSummary by Sourcery
Add a TOML updater for Gradle version catalogs and comprehensive tests and fixtures to validate version update behavior.
New Features:
Tests: