Repository navigation
Improve CLI output - #10
Conversation
📝 WalkthroughWalkthroughBanned-pattern diagnostics now include offending source line numbers. Summary output omits zero-valued ChangesDiagnostics and summary output
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/zsort.zig (1)
82-90: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winCalculate the line number only when a diagnostic is emitted.
Line 83 scans the source once for every
analysis.callsentry. A clean large file therefore performs repeated full-source scans. Move the count into each error branch.Proposed change
for (analysis.calls.items) |call| { - const line = std.mem.count(u8, source[0..call.offset], "\n") + 1; if (std.mem.indexOfScalar(usize, analysis.allowed.items, call.offset) == null) { + const line = std.mem.count(u8, source[0..call.offset], "\n") + 1; return allocFmt(allocator, "inline `@import` inside a type expression (line {d})", .{line}) orelse return error.OutOfMemory; } if (call.path) |path| { for (banned_prefixes) |prefix| { if (std.mem.startsWith(u8, path, prefix)) { + const line = std.mem.count(u8, source[0..call.offset], "\n") + 1; return allocFmt(allocator, "imports from '{s}' are not allowed (line {d})", .{ prefix, line }) orelse return error.OutOfMemory; } }🤖 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/zsort.zig` around lines 82 - 90, Update the loop over analysis.calls so the source line calculation is performed only inside the diagnostic branches that call allocFmt, including the inline type-expression and banned import checks. Remove the unconditional line declaration and compute it immediately before each relevant error message.
🤖 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 `@src/zsort.zig`:
- Around line 82-90: Update the loop over analysis.calls so the source line
calculation is performed only inside the diagnostic branches that call allocFmt,
including the inline type-expression and banned import checks. Remove the
unconditional line declaration and compute it immediately before each relevant
error message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9ed053fd-06bc-4dde-82ff-c12ea144b5bb
📒 Files selected for processing (3)
CHANGELOG.mdsrc/zsort.zigsrc/zsort_test.zig
Summary by CodeRabbit
Bug Fixes
Documentation