Skip to content

test(coverage): 100% line coverage of src/, enforced in CI - #28

Merged
Nejcc merged 6 commits into
mainfrom
test/full-coverage
Oct 31, 2026
Merged

Nejcc merged 6 commits into
mainfrom
test/full-coverage

Conversation

@Nejcc

@Nejcc Nejcc commented Oct 31, 2026

Copy link
Copy Markdown
Member

Refs #22

What

  • 195 tests (was 97), 100% line coverage of src/. CI's coverage job now runs pest --coverage --min=100. No @codeCoverageIgnore.
  • laravel/ai ^1.3 added to require-dev, so the agents, tools and AI endpoints are tested with Agent::fake() and Http::fake() (no real provider calls). laravel/mcp dev constraint moved to ^1.0 because laravel/ai needs it. src/Ai is no longer excluded from Larastan, and 5 stale baseline entries are gone.
  • DigDeep::$aiSdkAvailable: a small test seam so the "laravel/ai missing → 501" path stays tested.

Bugs found and fixed

  • trigger/replay and the MCP profile-url tool read the route from the cloned sub-request, so it was always null. Unknown URLs were stored as 500 instead of 404.
  • The logs page returned 500 on an empty log file (fread() with length 0).
  • ai-investigate returned 500 when a trace frame had no function key.
  • Query caller detection skipped any path containing /digdeep/, so apps living in such a path reported every caller as unknown. It now skips only the package's own src/.

Removed as unreachable

Empty-input guards in the percentile helpers, the session try/catch behind hasSession(), the stats() no-row branch, an object branch in InertiaCollector (props come from json_decode as arrays), a try/catch around a non-throwing json_encode, and a null fallback on a non-nullable command name.

Checks

lint, analyse and gitleaks clean.

Nejcc added 6 commits October 31, 2026 16:25
…gate

A trace frame lacking the function key raised an undefined array key
error and the endpoint answered 500 instead of prompting the agent.
fread() with a zero length throws a ValueError, so an empty file in
storage/logs made the whole page answer 500. Read the tail with
file_get_contents() and an offset instead.
Application::handle() clones the sub-request, so $subRequest->route()
was always null and trigger/replay profiles stored no route data. The
MCP profile-url tool matched the route after the fact, which threw for
unknown URLs and turned a 404 into a recorded 500. Read the route from
the bound request instead.
Add laravel/ai to require-dev and test the agents and source-file tools
with its fakes and Http::fake(); laravel/ai needs laravel/mcp ^1.0, so
the dev constraint moves up and src/Ai is no longer excluded from
PHPStan. DigDeep::$aiSdkAvailable lets tests simulate a missing SDK.

Unreachable code is removed rather than ignored: empty-input guards in
the percentile helpers, the session try/catch, the stats null check and
a few always-true conditions. The coverage job now runs with --min=100.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · 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

@Nejcc
Nejcc merged commit d7e1759 into main Oct 31, 2026
8 checks passed
@Nejcc
Nejcc deleted the test/full-coverage branch November 2, 2026 07:48
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