schemas: Indent .lock.json for readability - #231
Conversation
The schema lock file (.lock.json) was written on a single line, making it hard to read and prone to merge conflicts whenever more than one dependency changed. Write it with json.MarshalIndent (two-space indent) and a trailing newline so each dependency is on its own line. Reads are unaffected; getLock decodes the file with a json.Decoder and indented JSON remains valid. Fixes crossplane#168 Signed-off-by: Bham06 <heu319@student.bham.ac.uk>
📝 WalkthroughWalkthrough
ChangesSchema lock formatting
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/schemas/manager/manager_test.go (1)
174-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the required table-driven test structure.
This test covers the right behavior, but
*_test.gofiles must use table-driven cases with anargs/wantshape. Please move the lock input and expected serialized output into a test case and run it throught.Run;cmp.Diffis already appropriate here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/schemas/manager/manager_test.go` around lines 174 - 204, The TestUpdateLockIsIndented test must use the required table-driven args/want structure. Refactor the test to place the lock input and expected serialized output in a test case, iterate over the cases with t.Run, and keep the existing updateLock, file-read, and cmp.Diff assertions within the case execution.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/schemas/manager/manager_test.go`:
- Around line 174-204: The TestUpdateLockIsIndented test must use the required
table-driven args/want structure. Refactor the test to place the lock input and
expected serialized output in a test case, iterate over the cases with t.Run,
and keep the existing updateLock, file-read, and cmp.Diff assertions within the
case execution.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3db44ebd-3ab6-4dbf-b450-462329392d67
📒 Files selected for processing (2)
internal/schemas/manager/manager.gointernal/schemas/manager/manager_test.go
Description of your changes
schemas/.lock.jsonwas written on a single line, which is hard to read andcauses avoidable merge conflicts whenever more than one dependency changes.
This writes the lock file with
json.MarshalIndent(two-space indent) plus atrailing newline, so each dependency is on its own line. Reads are unaffected:
getLockdecodes with ajson.Decoder, and indented JSON is still valid. Mapkeys marshal in sorted order, so the output is deterministic.
Fixes #168
I have:
RunRan./nix.sh flake checkto ensure this PR is ready for review.go test ./internal/schemas/manager/... ./internal/dependency/...,go vet, andgofmt, and reviewed the change against.golangci.yml; relied on CI for the full flake check.TestUpdateLockIsIndented.)Linked a PR or a docs tracking issue to document this change.Internal on-disk lock file format; no user-facing docs.AddedMinor readability change; left to maintainer discretion.backport release-x.ylabels to auto-backport this PR.