docs: add null-narrowing and log-mocking conventions to CLAUDE.md#260
Open
kinyoklion wants to merge 1 commit intomainfrom
Open
docs: add null-narrowing and log-mocking conventions to CLAUDE.md#260kinyoklion wants to merge 1 commit intomainfrom
kinyoklion wants to merge 1 commit intomainfrom
Conversation
Two patterns that should be applied consistently across the repo: - Prefer Dart 3 case-pattern null narrowing (`if (x case final v?)`) over the `!` operator. Case-patterns introduce a non-null local without runtime assertion, avoiding surprise `TypeError`s. - For tests that capture log output, use mocktail's `Mock implements LDLogAdapter` plus `verify(...).captured` rather than hand-rolling a capturing adapter. This matches the pattern used in five existing test files (validating_persistence_test.dart, hook_runner_test.dart, env_context_modifier_test.dart, operations_test.dart, anonymous_context_modifier_test.dart). CLAUDE.md is loaded into context for every Claude Code session in this repo, so codifying these here makes them the default for both human contributors and AI agents.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two patterns that should be applied consistently across the repo:
if (x case final v?)) over the!operator. Case-patterns introduce a non-null local without runtime assertion, avoiding surpriseTypeErrors.Mock implements LDLogAdapterplusverify(...).capturedrather than hand-rolling a capturing adapter. This matches the pattern used in five existing test files (validating_persistence_test.dart, hook_runner_test.dart, env_context_modifier_test.dart, operations_test.dart, anonymous_context_modifier_test.dart).CLAUDE.md is loaded into context for every Claude Code session in this repo, so codifying these here makes them the default for both human contributors and AI agents.
Note
Low Risk
Low risk: documentation-only changes with no runtime behavior impact.
Overview
Updates
CLAUDE.mdto codify two new conventions: prefer Dart 3 case-pattern null narrowing over!, and standardize log-capture in tests usingmocktail(Mock implements LDLogAdapter+verify(...captureAny())) withvalidating_persistence_test.dartas the reference pattern.Reviewed by Cursor Bugbot for commit d6dfe53. Bugbot is set up for automated code reviews on this repo. Configure here.