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

Closed
opened 2026-06-12 00:32:58 -05:00 by forgejo-actions · 1 comment

SonarQube issue detected.

SonarQube key: adea9355-a34d-404d-9bc6-d0e316e8167e
Severity: CRITICAL
Type: CODE_SMELL
Location: myvideogamelist:app/Console/Commands/SyncProdProfileComments.php:37
Message: Refactor this function to reduce its Cognitive Complexity from 31 to the 15 allowed.

https://sonarqube.linuxbox.ninja/project/issues?id=myvideogamelist&issues=adea9355-a34d-404d-9bc6-d0e316e8167e&open=adea9355-a34d-404d-9bc6-d0e316e8167e

SonarQube issue detected. **SonarQube key:** `adea9355-a34d-404d-9bc6-d0e316e8167e` **Severity:** `CRITICAL` **Type:** `CODE_SMELL` **Location:** `myvideogamelist:app/Console/Commands/SyncProdProfileComments.php:37` **Message:** Refactor this function to reduce its Cognitive Complexity from 31 to the 15 allowed. https://sonarqube.linuxbox.ninja/project/issues?id=myvideogamelist&issues=adea9355-a34d-404d-9bc6-d0e316e8167e&open=adea9355-a34d-404d-9bc6-d0e316e8167e <!-- sonarqube:issue:adea9355-a34d-404d-9bc6-d0e316e8167e -->
Codex self-assigned this 2026-06-12 09:14:54 -05:00
Member

Fixed

  • Reduced cognitive complexity in production sync helpers and specialized sync commands by extracting validation, write, payload, and target-safety helpers.
  • Reduced UserFriendController::store() branching by extracting self-friend and friendship persistence helpers.
  • Split admin/user and settings media URL resolution into small path and storage helpers.
  • Moved the Profile social-handle validation rule into the persistence trait that uses it.
  • Split long Pest helper functions into setup/assertion helpers.
  • Moved private admin game form, IGDB, lookup, and media helpers into SupportsGameForms, reducing Admin\GameController to 20 declared methods.
  • Added UnknownUserSiteSettings for the migration guard instead of throwing a generic runtime exception.

Commit: 85719ea

Verification

vendor/bin/pint --dirty --format agent
git diff --check
php artisan test --compact tests/Feature/Settings/ProfileUpdateTest.php tests/Feature/SyncProdProfileCommentsCommandTest.php tests/Feature/SyncProdUserSiteSettingsCommandTest.php tests/Feature/SyncDevOgFavoritesCommandTest.php tests/Feature/NewlyAddedGamesPageTest.php tests/Feature/PlatformIndexTest.php tests/Feature/AdminGameIgdbCreateTest.php tests/Feature/AdminGameGenreTest.php tests/Feature/AdminGameRegionalOrderingTest.php tests/Feature/AdminGameCleanupTest.php tests/Feature/GameRequestTest.php tests/Feature/UserFriendTest.php

Result: 145 passed, 1372 assertions.

## Fixed - Reduced cognitive complexity in production sync helpers and specialized sync commands by extracting validation, write, payload, and target-safety helpers. - Reduced `UserFriendController::store()` branching by extracting self-friend and friendship persistence helpers. - Split admin/user and settings media URL resolution into small path and storage helpers. - Moved the Profile social-handle validation rule into the persistence trait that uses it. - Split long Pest helper functions into setup/assertion helpers. - Moved private admin game form, IGDB, lookup, and media helpers into `SupportsGameForms`, reducing `Admin\GameController` to 20 declared methods. - Added `UnknownUserSiteSettings` for the migration guard instead of throwing a generic runtime exception. Commit: `85719ea` ## Verification ```bash vendor/bin/pint --dirty --format agent git diff --check php artisan test --compact tests/Feature/Settings/ProfileUpdateTest.php tests/Feature/SyncProdProfileCommentsCommandTest.php tests/Feature/SyncProdUserSiteSettingsCommandTest.php tests/Feature/SyncDevOgFavoritesCommandTest.php tests/Feature/NewlyAddedGamesPageTest.php tests/Feature/PlatformIndexTest.php tests/Feature/AdminGameIgdbCreateTest.php tests/Feature/AdminGameGenreTest.php tests/Feature/AdminGameRegionalOrderingTest.php tests/Feature/AdminGameCleanupTest.php tests/Feature/GameRequestTest.php tests/Feature/UserFriendTest.php ``` Result: `145 passed, 1372 assertions`.
Codex 2026-06-12 09:28:56 -05:00
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#731
No description provided.