SonarQube CRITICAL CODE_SMELL: Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allo #897

Closed
opened 2026-08-04 16:56:31 -05:00 by forgejo-actions · 1 comment

SonarQube issue detected.

SonarQube key: 50a1c1ff-c02c-4607-9d97-d932ae3fc26c
Severity: CRITICAL
Type: CODE_SMELL
Location: myvideogamelist:app/Console/Commands/SyncProductionSnapshot.php:28
Message: Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.

https://sonarqube.linuxbox.ninja/project/issues?id=myvideogamelist&issues=50a1c1ff-c02c-4607-9d97-d932ae3fc26c&open=50a1c1ff-c02c-4607-9d97-d932ae3fc26c

SonarQube issue detected. **SonarQube key:** `50a1c1ff-c02c-4607-9d97-d932ae3fc26c` **Severity:** `CRITICAL` **Type:** `CODE_SMELL` **Location:** `myvideogamelist:app/Console/Commands/SyncProductionSnapshot.php:28` **Message:** Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed. https://sonarqube.linuxbox.ninja/project/issues?id=myvideogamelist&issues=50a1c1ff-c02c-4607-9d97-d932ae3fc26c&open=50a1c1ff-c02c-4607-9d97-d932ae3fc26c <!-- sonarqube:issue:50a1c1ff-c02c-4607-9d97-d932ae3fc26c -->
Codex self-assigned this 2026-08-04 18:50:25 -05:00
Member

Resolved by PR #914.

Notes for future readers:

  • Content flag test-only Sonar findings were handled by extracting repeated profile/content literals into named constants and replacing the nested ternary helper with explicit owner resolution.
  • The unused ContentFlagTargetResolver::isHidden() $type parameter was removed because the method resolves hidden state from the model class and id.
  • Production sync command findings were handled by introducing ProductionSyncCommandException, using it for command/preflight/process failures, and splitting the production data/snapshot command flow into smaller helpers to reduce return count and cognitive complexity.
  • The legacy mvgl:sync-production-snapshot command remains retired per docs/DEV_PRODUCTION_PARITY.md; the cleanup preserves its existing dry-run/write/rollback behavior while satisfying the analyzer.

Verification from the PR:

  • php artisan test --compact tests/Feature/ContentFlagTest.php tests/Feature/ProductionDataSyncCommandTest.php tests/Feature/ProductionSnapshotCommandTest.php
  • vendor/bin/pint --dirty --format agent
  • composer stan
Resolved by PR #914. Notes for future readers: - Content flag test-only Sonar findings were handled by extracting repeated profile/content literals into named constants and replacing the nested ternary helper with explicit owner resolution. - The unused `ContentFlagTargetResolver::isHidden()` `$type` parameter was removed because the method resolves hidden state from the model class and id. - Production sync command findings were handled by introducing `ProductionSyncCommandException`, using it for command/preflight/process failures, and splitting the production data/snapshot command flow into smaller helpers to reduce return count and cognitive complexity. - The legacy `mvgl:sync-production-snapshot` command remains retired per `docs/DEV_PRODUCTION_PARITY.md`; the cleanup preserves its existing dry-run/write/rollback behavior while satisfying the analyzer. Verification from the PR: - `php artisan test --compact tests/Feature/ContentFlagTest.php tests/Feature/ProductionDataSyncCommandTest.php tests/Feature/ProductionSnapshotCommandTest.php` - `vendor/bin/pint --dirty --format agent` - `composer stan`
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MyVideoGameList/myvideogamelist.com#897
No description provided.