perf: cache validator severity and drop per-comparison reflection#148
perf: cache validator severity and drop per-comparison reflection#148konradmichalik wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesSeverity resolution
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.2.2)PHPStan was skipped because the config uses disallowed 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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Result/ValidationResultCliRenderer.php (1)
227-229: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer
instanceof XliffSchemaValidatorhere.str_contains($class, 'SchemaValidator')is brittle name-based dispatch; a direct type check is clearer and keeps the special case tied to the actual validator class. Adduse MoveElevator\ComposerTranslationValidator\Validator\XliffSchemaValidator;.🤖 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/Result/ValidationResultCliRenderer.php` around lines 227 - 229, The severity special case in the severity resolution logic uses brittle class-name matching. Import XliffSchemaValidator and replace the str_contains($class, 'SchemaValidator') condition with an instanceof XliffSchemaValidator check, preserving the existing cached severity behavior.
🤖 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/Result/ValidationResultCliRenderer.php`:
- Around line 227-229: The severity special case in the severity resolution
logic uses brittle class-name matching. Import XliffSchemaValidator and replace
the str_contains($class, 'SchemaValidator') condition with an instanceof
XliffSchemaValidator check, preserving the existing cached severity behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 513dc6fb-7d13-42ab-be11-83d1d2abb64b
📒 Files selected for processing (1)
src/Result/ValidationResultCliRenderer.php
Summary
ReflectionClassand a fresh validator instance on every pairwise comparison to readresultTypeOnValidationFailure(). For a file with many issues this meant thousands of reflection instantiations.Changes
src/Result/ValidationResultCliRenderer.php— resolve severity from the validator instance with a per-class cache; route group sorting through the same path; drop the reflection-based helper and its now-unused importsSummary by CodeRabbit