fix: Add SonarCloud test configuration and refactor repository tests#37
fix: Add SonarCloud test configuration and refactor repository tests#37
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 40 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughCI and test infrastructure updates: SonarCloud test configuration added to CI workflow, Trivy scanner updated and configured to check critical vulnerabilities only, test base class extended with conditional migration support, and integration tests refactored to leverage shared base class infrastructure instead of duplicated database management code. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/Unit/Domain/Asset/ValueObject/AssetIdTest.php`:
- Around line 83-87: The helper method createAssetId that simply returns new
AssetId($value) is unnecessary indirection; remove the private function
createAssetId(string $value): AssetId and replace its usages in tests with
direct instantiation new AssetId($value) (e.g., in tests like
itReturnsSameValueWhenConstructedWithValidUuidV4) for clarity — if you must keep
it for static analysis or coverage, add a brief comment above createAssetId
explaining why it exists.
- Line 66: Remove the trailing whitespace on the blank/affected line in the
AssetIdTest class (AssetIdTest.php) that is causing PHP CS Fixer to fail; open
the AssetIdTest file, locate the line near the test methods in class AssetIdTest
(around the test declarations), delete any trailing spaces at end-of-line, save,
and re-run the linter/CI to confirm the whitespace-only change resolves the
failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f3f447a5-881f-4068-9962-1ab64ade452c
📒 Files selected for processing (6)
.github/workflows/ci.yml.github/workflows/trivy.ymltests/Integration/Infrastructure/Persistence/BaseAssetsTableTestCase.phptests/Integration/Infrastructure/Persistence/MySQLAssetRepositoryTest.phptests/Unit/Domain/Asset/ValueObject/AssetIdTest.phptests/Unit/Domain/Asset/ValueObject/UploadTargetTest.php
Summary
This PR addresses quality gates issues across the CI/CD pipeline and test infrastructure by:
SonarCloud Configuration — Extended the SonarQube scan step with test discovery parameters (
-Dsonar.tests=testsand-Dsonar.test.inclusions=tests/**) to ensure thetestsdirectory is properly analyzed during quality scanning.Trivy Security Scanning — Updated Trivy CLI from v0.69.2 to v0.69.3 and refined container image scanning to focus on vulnerability scanning only (
--scanners vuln) with severity filtering toCRITICALlevel (previouslyHIGH,CRITICAL).Test Infrastructure Refactoring — Consolidated database test harness by:
BaseAssetsTableTestCase::$selectedConnectionvisibility fromprivatetoprotectedto enable subclass access$applyMigrationparameter towithTemporarySchema()to conditionally apply migrations during test setupMySQLAssetRepositoryTest Consolidation — Removed 205 lines of redundant local database bootstrap code by migrating to
BaseAssetsTableTestCase, introducing reusable test helpers (createRepository(),assertFoundByIdAndUploadId(),assertPersistedSingleRowMatches()), and extracting constants (STALE_ASSET_WRITE_MESSAGE, timestamp constants).Test Quality Markers — Added
// NOSONARinline comments to test data providers inUploadTargetTest.phpto suppress false positives on intentional insecure URLs and localhost patterns used for local development testing.AssetIdTest Enhancement — Introduced a private
createAssetId()helper method for test instantiation to maintain consistency with code organization patterns.Net Impact: -205 lines in MySQLAssetRepositoryTest (644 lines → centralized via base class), +2 lines in CI workflow, +3 lines in Trivy workflow, improved test maintainability, and quality gate compliance through proper configuration and annotation.