Skip to content

fix: show failure details in compact mode#32

Open
jordanpartridge wants to merge 6 commits intomasterfrom
fix/compact-mode-failure-details
Open

fix: show failure details in compact mode#32
jordanpartridge wants to merge 6 commits intomasterfrom
fix/compact-mode-failure-details

Conversation

@jordanpartridge
Copy link
Contributor

@jordanpartridge jordanpartridge commented Dec 21, 2025

Summary

Fixes #24 - Compact mode now displays failure details when checks fail, preventing developers from having to re-run tests in verbose mode to see what went wrong.

Problem

When running gate with --compact, failures showed only checkmarks with no details:

Tests ✗  Security ✓  Syntax ✓  │  ✗ REJECTED

Developers had no information about:

  • Which tests failed
  • What the coverage percentage is
  • Which files need coverage
  • What the error messages are

Solution

Modified CertifyCommand.php to display the failure details table even in compact mode when verdict is rejected. The compact summary is still shown first, followed by the detailed failure table.

Before:

Tests ✗  Security ✓  Syntax ✓  │  ✗ REJECTED

After:

Tests ✗  Security ✓  Syntax ✓  │  ✗ REJECTED

┌──────────────────┬────────────────────────────────────────┐
│ Check            │ Issue                                  │
├──────────────────┼────────────────────────────────────────┤
│ Tests & Coverage │ FooTest::it does something (FooTest.p… │
│ Tests & Coverage │ Coverage below 100%: BarService (99.5%)│
└──────────────────┴────────────────────────────────────────┘

Changes

  • Modified CertifyCommand::handle() to show failureRows table after compact output when verdict is not approved
  • Added comprehensive tests for compact mode failure display
  • Maintains 100% test coverage
  • Applied Laravel Pint formatting

Test Plan

  • ✅ All existing tests pass
  • ✅ 100% test coverage maintained
  • ✅ New tests verify failure details are shown in compact mode
  • ✅ Existing compact mode tests still pass
  • ✅ Laravel Pint formatting applied

Summary by CodeRabbit

  • New Features

    • Added three new branding options for expanded check categories.
  • Improvements

    • Compact output now shows a separate failure details table when checks fail.
    • Widespread code formatting and style cleanup for consistency.
  • Tests

    • Expanded test coverage for certify command compact-mode behaviors and various pass/fail scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

Previously when running gate with --compact, failures would only show
a single line with checkmarks but provide NO details about what failed.
This made debugging impossible without re-running in verbose mode.

Now compact mode still shows the failure details table when checks fail,
providing developers with immediate actionable error information while
maintaining the compact summary format.

Changes:
- Modified CertifyCommand to display failureRows table in compact mode
  when verdict is rejected
- Added tests to verify failure details are shown in compact mode
- Maintains 100% test coverage

Fixes #24
@coderabbitai
Copy link

coderabbitai bot commented Dec 21, 2025

📝 Walkthrough

Walkthrough

This PR adds three branding constants (SECURITY, SYNTAX, CERTIFICATION) to App\Branding, updates CertifyCommand to show failure details in compact mode when the verdict is rejected, and applies widespread stylistic normalization (zero-arg constructor syntax, string-concat spacing, docblock/blank-line tweaks) across production and test files.

Changes

Cohort / File(s) Summary
Branding constants expansion
app/Branding.php
Added public constants SECURITY, SYNTAX, CERTIFICATION and updated checkName mappings.
Compact-mode failure details
app/Commands/CertifyCommand.php
When --compact is used and the verdict is rejected, compact summary is rendered AND failure details table is printed (if failures exist).
CertifyCommand compact tests
tests/Unit/Commands/CertifyCommandTest.php
Added numerous tests covering compact-mode failure detail display, multiple failure/passing scenarios, and option permutations.
Constructor syntax normalization (prod)
app/Checks/SecurityScanner.php, app/Checks/TestRunner.php, app/Commands/CertifyCommand.php, app/Commands/SecurityCommand.php, app/Commands/SyntaxCommand.php
Replaced new ClassName() with new ClassName for zero-arg instantiations.
Constructor syntax normalization (tests)
tests/... (many files)
Applied same zero-arg constructor syntax normalization across test suites (e.g., tests/Feature/*, tests/Unit/*).
String concatenation formatting
app/Checks/PestSyntaxValidator.php, app/Services/CoverageReporter.php, app/Services/PestOutputParser.php, tests/...
Normalized spacing around . concatenation (tightened expressions like sys_get_temp_dir().'/path').
Minor formatting & imports
app/Checks/CheckInterface.php, app/GitHub/ChecksClient.php, app/GitHub/CommentsClient.php, app/Stages/TechnicalGate.php, app/Verdict.php, tests/Feature/TechnicalGateTest.php, tests/Unit/GitHub/ChecksClientTest.php
Blank-line/docblock alignment and import reorder changes; no behavioral changes.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI
    participant CertifyCommand
    participant CheckRunner
    participant TableRenderer

    User->>CLI: run gate --compact
    CLI->>CertifyCommand: invoke handle()
    CertifyCommand->>CheckRunner: run checks (Tests, Security, Syntax, ...)
    CheckRunner-->>CertifyCommand: results + verdict
    CertifyCommand->>CertifyCommand: build compactResults + failureRows
    alt verdict approved
        CertifyCommand->>CLI: print compact summary (approved)
    else verdict rejected
        CertifyCommand->>CLI: print compact summary (rejected)
        CertifyCommand->>TableRenderer: render failure table (failureRows)
        TableRenderer-->>CLI: printed failure details
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hop hop, the code now stands so neat,
No trailing parens, formatting sweet!
Compact mode sings, failures shown in view,
Branding grows with three more hues,
A rabbit cheers — debug made true!

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes extensive code formatting changes (removing parentheses from zero-arg constructors, normalizing string concatenation) and import reordering that are unrelated to fixing compact mode failure display. Separate formatting and style changes into a dedicated PR to keep this focused on the compact mode fix. The core fix should remain isolated from cosmetic code changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 5.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: displaying failure details in compact mode, which directly addresses issue #24.
Linked Issues check ✅ Passed The PR fully implements the requirements from issue #24: CertifyCommand now shows failure details table when compact mode is enabled and verdict is rejected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

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

jordanpartridge and others added 4 commits December 20, 2025 23:31
Add expectOutputRegex() calls to tests that output failure tables in compact mode.
PHPUnit's beStrictAboutOutputDuringTests setting requires tests to explicitly
expect output, otherwise they are marked as risky and fail in CI.

Tests now properly declare they expect output when running certify --compact
with failures, preventing risky test warnings while maintaining test coverage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add expectOutputRegex() calls to all tests that output in compact mode.
PHPUnit's beStrictAboutOutputDuringTests setting requires tests to explicitly
expect output, otherwise they are marked as risky and fail in CI.

Tests now properly declare they expect output when running certify --compact,
preventing risky test warnings while maintaining 100% test coverage.

Fixes:
- Added expectOutputRegex to "outputs compact format when --compact option is set and all checks pass"
- Added expectOutputRegex to "outputs compact format when --compact option is set and a check fails"
- Added expectOutputRegex to "shows failure details in compact mode when checks fail"
- Added expectOutputRegex to "shows failure details for multiple failing checks in compact mode"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add expectOutputRegex() to capture table output in compact mode tests
- Add expectsOutputToContain('✗ REJECTED') assertions to verify output
- Fixes risky test warnings for compact mode failure detail tests
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @tests/Unit/Commands/CertifyCommandTest.php:
- Around line 395-424: The test "does not show failure table in compact mode
when all checks pass" is missing the expectOutputRegex('/.*/s') call which other
compact-mode tests include; add ->expectOutputRegex('/.*/s') into the assertion
chain on $this->artisan('certify', ['--compact' => true]) (the same chain that
currently calls ->assertSuccessful()->expectsOutputToContain('✓
APPROVED')->doesntExpectOutputToContain('Check')->doesntExpectOutputToContain('Issue')
) so PHPUnit's strict output mode won't mark the test as risky.
🧹 Nitpick comments (1)
tests/Unit/Commands/CertifyCommandTest.php (1)

362-393: Consider adding explicit assertions for failure detail content.

Both tests verify that compact mode "shows failure details" (as stated in their names), but they only assert the presence of the verdict ('✗ REJECTED'), not the actual failure details. To more thoroughly verify the PR objective—that failure details are displayed in compact mode—consider adding assertions for specific failure content.

For example, in the first test you could check for the failure details that were set up:

->expectsOutputToContain('FooTest failed')
->expectsOutputToContain('BarTest failed');

Or verify the failure table headers are present:

->expectsOutputToContain('Check')
->expectsOutputToContain('Issue');

This would provide stronger evidence that the failure details table is actually rendered, not just the verdict.

Also applies to: 426-454

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2652abb and 78c2265.

📒 Files selected for processing (1)
  • tests/Unit/Commands/CertifyCommandTest.php
🧰 Additional context used
🧬 Code graph analysis (1)
tests/Unit/Commands/CertifyCommandTest.php (3)
app/Commands/CertifyCommand.php (1)
  • CertifyCommand (21-226)
app/Checks/CheckResult.php (3)
  • CheckResult (7-24)
  • fail (20-23)
  • pass (15-18)
app/GitHub/ChecksClient.php (1)
  • ChecksClient (10-203)
🔇 Additional comments (2)
tests/Unit/Commands/CertifyCommandTest.php (2)

17-17: LGTM: Modern PHP syntax for zero-argument constructors.

The removal of parentheses for zero-argument constructor invocation is valid PHP 8.0+ syntax and aligns with the project-wide modernization mentioned in the PR summary.


292-293: LGTM: Proper PHPUnit output expectations.

The expectOutputRegex('/.*/s') calls correctly declare expected output to satisfy PHPUnit's strict output mode, preventing "risky test" warnings. The explanatory comment on line 321 is helpful.

Also applies to: 321-322

Comment on lines +395 to +424
it('does not show failure table in compact mode when all checks pass', function () {
$testsCheck = Mockery::mock(CheckInterface::class);
$testsCheck->shouldReceive('name')->andReturn('Tests & Coverage');
$testsCheck->shouldReceive('run')
->once()
->andReturn(CheckResult::pass('All tests passed'));

$securityCheck = Mockery::mock(CheckInterface::class);
$securityCheck->shouldReceive('name')->andReturn('Security Audit');
$securityCheck->shouldReceive('run')
->once()
->andReturn(CheckResult::pass('No vulnerabilities'));

$mock = new MockHandler([
new Response(201),
new Response(201),
new Response(201),
]);
$httpClient = new Client(['handler' => HandlerStack::create($mock)]);
$checksClient = new ChecksClient('token', $httpClient, 'owner/repo', 'sha123');

($this->createCommand)([$testsCheck, $securityCheck], $checksClient);

// Should only output compact summary, no failure table
$this->artisan('certify', ['--compact' => true])
->assertSuccessful()
->expectsOutputToContain('✓ APPROVED')
->doesntExpectOutputToContain('Check')
->doesntExpectOutputToContain('Issue');
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add expectOutputRegex for consistency and to prevent risky test warnings.

This test produces output (the compact summary) but is missing the expectOutputRegex('/.*/s') call that other compact mode tests include (lines 292, 321, 388, 449). Without it, PHPUnit's strict output mode may flag this test as risky.

🔧 Suggested fix
     ($this->createCommand)([$testsCheck, $securityCheck], $checksClient);
 
+    $this->expectOutputRegex('/.*/s');
+
     // Should only output compact summary, no failure table
     $this->artisan('certify', ['--compact' => true])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('does not show failure table in compact mode when all checks pass', function () {
$testsCheck = Mockery::mock(CheckInterface::class);
$testsCheck->shouldReceive('name')->andReturn('Tests & Coverage');
$testsCheck->shouldReceive('run')
->once()
->andReturn(CheckResult::pass('All tests passed'));
$securityCheck = Mockery::mock(CheckInterface::class);
$securityCheck->shouldReceive('name')->andReturn('Security Audit');
$securityCheck->shouldReceive('run')
->once()
->andReturn(CheckResult::pass('No vulnerabilities'));
$mock = new MockHandler([
new Response(201),
new Response(201),
new Response(201),
]);
$httpClient = new Client(['handler' => HandlerStack::create($mock)]);
$checksClient = new ChecksClient('token', $httpClient, 'owner/repo', 'sha123');
($this->createCommand)([$testsCheck, $securityCheck], $checksClient);
// Should only output compact summary, no failure table
$this->artisan('certify', ['--compact' => true])
->assertSuccessful()
->expectsOutputToContain('✓ APPROVED')
->doesntExpectOutputToContain('Check')
->doesntExpectOutputToContain('Issue');
});
it('does not show failure table in compact mode when all checks pass', function () {
$testsCheck = Mockery::mock(CheckInterface::class);
$testsCheck->shouldReceive('name')->andReturn('Tests & Coverage');
$testsCheck->shouldReceive('run')
->once()
->andReturn(CheckResult::pass('All tests passed'));
$securityCheck = Mockery::mock(CheckInterface::class);
$securityCheck->shouldReceive('name')->andReturn('Security Audit');
$securityCheck->shouldReceive('run')
->once()
->andReturn(CheckResult::pass('No vulnerabilities'));
$mock = new MockHandler([
new Response(201),
new Response(201),
new Response(201),
]);
$httpClient = new Client(['handler' => HandlerStack::create($mock)]);
$checksClient = new ChecksClient('token', $httpClient, 'owner/repo', 'sha123');
($this->createCommand)([$testsCheck, $securityCheck], $checksClient);
$this->expectOutputRegex('/.*/s');
// Should only output compact summary, no failure table
$this->artisan('certify', ['--compact' => true])
->assertSuccessful()
->expectsOutputToContain('✓ APPROVED')
->doesntExpectOutputToContain('Check')
->doesntExpectOutputToContain('Issue');
});
🤖 Prompt for AI Agents
In @tests/Unit/Commands/CertifyCommandTest.php around lines 395 - 424, The test
"does not show failure table in compact mode when all checks pass" is missing
the expectOutputRegex('/.*/s') call which other compact-mode tests include; add
->expectOutputRegex('/.*/s') into the assertion chain on
$this->artisan('certify', ['--compact' => true]) (the same chain that currently
calls ->assertSuccessful()->expectsOutputToContain('✓
APPROVED')->doesntExpectOutputToContain('Check')->doesntExpectOutputToContain('Issue')
) so PHPUnit's strict output mode won't mark the test as risky.

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.

Compact mode hides critical failure details making debugging impossible

1 participant