Add <auto-generated> header to output file - #66
Conversation
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthrough
ChangesGenerated header integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant generateCode
participant generated_header
participant GeneratorOutput
Caller->>generateCode: pass allocator, io, document, args
generateCode->>generated_header: renderNow version and timestamp
generated_header-->>generateCode: generated header
generateCode->>GeneratorOutput: write header and generated code
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/lib.zig (1)
227-230: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated version-string + header construction across
src/lib.zigandsrc/generator.zig. Both call sites independently format the same"{s} ({s})"version string and callgenerated_header.renderNowwith it; a small shared helper ingenerated_header.zigwould remove the duplication and keep both call sites in sync ifversion_infoor the header contract changes.
src/lib.zig#L227-L230: replace with a single call to a new helper, e.g.generated_header.renderNowFromBuildInfo(allocator, io, version_info).src/generator.zig#L128-L131: replace with the same helper call.♻️ Proposed shared helper
// src/generators/generated_header.zig pub fn renderNowFromBuildInfo(allocator: std.mem.Allocator, io: std.Io, version_info: anytype) ![]const u8 { const version = try std.fmt.allocPrint(allocator, "{s} ({s})", .{ version_info.VERSION, version_info.GIT_COMMIT }); defer allocator.free(version); return try renderNow(allocator, io, version); }🤖 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 `@src/lib.zig` around lines 227 - 230, Extract the duplicated version formatting and generated-header rendering into a shared renderNowFromBuildInfo helper in src/generators/generated_header.zig, preserving the existing allocator, io, version_info.VERSION, and version_info.GIT_COMMIT behavior. Replace the separate construction in src/lib.zig lines 227-230 and src/generator.zig lines 128-131 with calls to this helper, retaining appropriate header ownership cleanup at each call site.
🤖 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.
Inline comments:
In `@README.md`:
- Line 375: Update the generated output documentation near generateCode to
mention the versioned <auto-generated> header and clarify that regenerated Zig
sources may differ even when the API surface is unchanged.
In `@src/lib.zig`:
- Around line 224-241: The models_code allocation in the generation flow has
overlapping cleanup paths. Replace the errdefer and branch-specific cleanup
around generateModels with one unconditional defer allocator.free(models_code),
and remove the manual allocator.free(models_code) inside the args.models_only
branch while preserving both return paths.
In `@src/tests/generated_header_tests.zig`:
- Around line 5-17: Update both tests in the generated header test file to
import and use test_utils.createTestAllocator() instead of
std.testing.allocator. Initialize the allocator wrapper, obtain its allocator
for generated_header.render, and add the required cleanup defer consistent with
the project’s test pattern.
---
Nitpick comments:
In `@src/lib.zig`:
- Around line 227-230: Extract the duplicated version formatting and
generated-header rendering into a shared renderNowFromBuildInfo helper in
src/generators/generated_header.zig, preserving the existing allocator, io,
version_info.VERSION, and version_info.GIT_COMMIT behavior. Replace the separate
construction in src/lib.zig lines 227-230 and src/generator.zig lines 128-131
with calls to this helper, retaining appropriate header ownership cleanup at
each call site.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ae88574f-2fb6-43af-8c27-9879b60df9f4
⛔ Files ignored due to path filters (8)
generated/generated_v2.zigis excluded by!**/generated/**generated/generated_v2_yaml.zigis excluded by!**/generated/**generated/generated_v3.zigis excluded by!**/generated/**generated/generated_v31.zigis excluded by!**/generated/**generated/generated_v31_yaml.zigis excluded by!**/generated/**generated/generated_v32.zigis excluded by!**/generated/**generated/generated_v3_yaml.zigis excluded by!**/generated/**generated/lmstudio.zigis excluded by!**/generated/**
📒 Files selected for processing (7)
README.mdexamples/example_usage.zigsrc/generator.zigsrc/generators/generated_header.zigsrc/lib.zigsrc/tests.zigsrc/tests/generated_header_tests.zig
Summary by CodeRabbit
New Features
Documentation
Tests