Skip to content

Only collect debug info for the subcommands that show it - #22

Merged
swissspidy merged 1 commit into
mainfrom
claude/lazy-debug-data
Oct 6, 2026
Merged

swissspidy merged 1 commit into
mainfrom
claude/lazy-debug-data

Conversation

@swissspidy

@swissspidy swissspidy commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

The constructor collected WP_Debug_Data::debug_data() for every subcommand, but only info and list-info-sections use it.

On a test site with a few large plugins, collecting it took 220–540 ms. It also shells out to Ghostscript to check its version, which printed gs: not found on stderr where Ghostscript isn't installed.

It's now collected on first use, so wp site-health check and wp site-health status skip it. The output of info and list-info-sections doesn't change.

Tests

  • Feature suite: passes locally (5 scenarios). No new scenario: the existing ones cover info and list-info-sections, and the change has no visible effect apart from timing.
  • Static checks: PHPCS and PHPStan are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS


Generated by Claude Code

Summary by CodeRabbit

  • Improvements
    • Site Health information is now collected only when needed and reused during the command, avoiding repeated data collection.

The constructor collected `WP_Debug_Data::debug_data()` for every
subcommand, but only `info` and `list-info-sections` use it. On a test
site with a few large plugins it took 220-540 ms, and it shells out to
Ghostscript to check its version. Collect it on first use instead, so
`wp site-health check` and `wp site-health status` skip it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:28

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 723e95fa-9197-4165-9bec-09ff741e6da9
📥 Commits

Reviewing files that changed from the base of the PR and between e6ceb45 and bfe7882.

📒 Files selected for processing (1)
  • src/SiteHealthCommand.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

SiteHealthCommand now collects debug data when first needed and reuses the cached data for section listing and retrieval.

Changes

Site Health Info

Layer / File(s) Summary
Lazy debug data access
src/SiteHealthCommand.php
The $info property allows null. A new get_info() method collects debug data on first access and returns the cached data. Section listing and retrieval use this accessor.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: claude

Merge Risk: ⚪ Minimal · up to bfe78

The change defers debug-data collection until an info command needs it and reuses the result. No actionable merge risk is established by the supplied evidence.

🚥 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 clearly summarizes the main change: debug data is collected only when a subcommand needs it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files.
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 docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added command:site-health Related to 'site-health' command enhancement New feature or request labels Oct 6, 2026
@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 1.0.2 milestone Oct 6, 2026
@swissspidy
swissspidy merged commit ab3dd7b into main Oct 6, 2026
60 checks passed
@swissspidy
swissspidy deleted the claude/lazy-debug-data branch October 6, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:site-health Related to 'site-health' command enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants