Skip to content

Improve CLI output - #10

Merged
mstdokumaci merged 1 commit into
mainfrom
nice-output
Aug 5, 2026
Merged

mstdokumaci merged 1 commit into
mainfrom
nice-output

Conversation

@mstdokumaci

@mstdokumaci mstdokumaci commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Banned-import diagnostics now include the source line where the issue occurs.
    • Summary output now omits failure and banned counts when their values are zero.
    • Summary wording and formatting are more accurate for singular files and banned-only results.
  • Documentation

    • Updated the unreleased changelog to describe the diagnostic and summary improvements.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Banned-pattern diagnostics now include offending source line numbers. Summary output omits zero-valued failed and banned counts. Tests cover diagnostic line numbers, summary variants, count ordering, singular wording, and colored output.

Changes

Diagnostics and summary output

Layer / File(s) Summary
Line-numbered banned-pattern diagnostics
src/zsort.zig, src/zsort_test.zig
The scanner receives source text and reports one-based line numbers for inline and banned-prefix diagnostics. Tests cover multiline input.
Conditional summary counts
src/zsort.zig, src/zsort_test.zig, CHANGELOG.md
Summary formatting omits zero-valued counts and preserves nonzero count ordering, file wording, headers, and elapsed time. The changelog documents both output changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the changes to diagnostic messages and CLI summary formatting, although it does not specify the output improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nice-output

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/zsort.zig (1)

82-90: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Calculate the line number only when a diagnostic is emitted.

Line 83 scans the source once for every analysis.calls entry. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9be017a and 1da00c8.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/zsort.zig
  • src/zsort_test.zig

@mstdokumaci
mstdokumaci merged commit 556d6e5 into main Aug 5, 2026
10 checks passed
@mstdokumaci
mstdokumaci deleted the nice-output branch August 5, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant