Skip to content

Fix sonarqube issues#59

Open
dehy wants to merge 17 commits intomainfrom
fix/sonarqube-issues
Open

Fix sonarqube issues#59
dehy wants to merge 17 commits intomainfrom
fix/sonarqube-issues

Conversation

@dehy
Copy link
Owner

@dehy dehy commented Feb 27, 2026

Very dirty PR where I test Claude Sonnet 4.6 by giving him all the Sonarqube issues and let him fix all of them.

Needs careful review and maybe some rollback.

@dehy dehy marked this pull request as ready for review February 27, 2026 21:53
Copilot AI review requested due to automatic review settings February 27, 2026 21:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses SonarQube findings across the Symfony (PHP) backend and the TypeScript frontend by tightening error handling, removing dead code, reducing duplication, and applying small refactors to satisfy static analysis.

Changes:

  • Replace generic exceptions with domain-specific exceptions (Storage/Parse/FFTA) and propagate updated @throws docs.
  • Refactor/cleanup code to reduce duplication and “code smell” (constants for repeated strings/selectors, extracted helper logic, remove commented scaffolding).
  • Frontend lint/static-analysis tweaks (ES target bump, safer globals usage, minor refactors in Stimulus controllers and utilities).

Reviewed changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.json Bumps TS compilation target to ES2021.
src/Twig/PublicUrlExtension.php Throws StorageException instead of generic \Exception.
src/Twig/AttachmentTemporaryUrlExtension.php Throws StorageException for temp URL failures.
src/Scrapper/ResultArcParser.php Throws ParseException instead of generic \Exception.
src/Scrapper/FftaScrapper.php Introduces selector constant; throws FftaException for request failure.
src/Repository/SightAdjustmentRepository.php Removes commented template methods.
src/Repository/ResultRepository.php Removes commented template methods.
src/Repository/PracticeAdviceRepository.php Removes commented template methods.
src/Repository/LicenseeRepository.php Removes commented template methods.
src/Repository/LicenseeAttachmentRepository.php Removes commented template methods.
src/Repository/LicenseRepository.php Removes commented template methods.
src/Repository/GroupRepository.php Removes commented template methods.
src/Repository/EventParticipationRepository.php Removes commented template methods.
src/Repository/BowRepository.php Removes commented template methods.
src/Repository/ArrowRepository.php Removes commented template methods.
src/Helper/StringHelper.php Refactors password generation to functional style.
src/Helper/ObjectComparator.php Adds NOSONAR suppression for intentional loose comparison.
src/Helper/LicenseHelper.php Extracts birthdate/dateKey matching into a dedicated method.
src/Helper/FftaHelper.php Refactors licensee sync flow; extracts methods; updates exceptions/docs.
src/Exception/StorageException.php Adds new domain exception.
src/Exception/ParseException.php Adds new domain exception.
src/Exception/FftaException.php Adds new domain exception.
src/Entity/Result.php Minor refactors in parsing and distance/size logic (but introduces a syntax error).
src/Entity/Event.php Extracts date format string into a constant.
src/Controller/ResetPasswordController.php Refactor to reduce early return / simplify flow.
src/Controller/RegistrationController.php Condenses null/id handling into a single assignment.
src/Controller/GroupManagementController.php Refactor to avoid duplicate returns by reusing a response variable.
src/Controller/Admin/EventManagementController.php Removes unused GroupRepository injection/import.
src/Controller/Admin/AdminDashboardController.php Extracts repeated icon class into a constant.
src/Command/ResultArcImportCommand.php Consolidates validation into a single conditional branch.
src/Command/DiscordBotRunCommand.php Simplifies event callback signature.
assets/pdf.ts Minor JS/TS best-practice tweaks (new Error, parseFloat usage, etc.).
assets/custom-svg-icons/faBowClassicRecurve.js Replaces var with const.
assets/cookie-consent.ts Improves typings and uses globalThis for Matomo queue.
assets/controllers/results-chart_controller.ts Names controller class; removes unused locals.
assets/controllers/modal_controller.ts Names controller class; refactors null checks / early return; target declaration tweak.
assets/controllers/event-participation_controller.ts Names controller class; fixes equality check / UI toggle logic.
assets/app.ts Removes commented/dead code.
assets/apiCore.ts Simplifies query string assembly using flat().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +180 to +191
$this->entityManager->beginTransaction();
$this->entityManager->persist($licensee);

if ($dbProfilePicture && !$fftaProfilePicture instanceof LicenseeAttachment) {
$this->logger->notice(' - Removing profile picture');
$licensee->removeAttachment($dbProfilePicture);
$this->entityManager->remove($dbProfilePicture);
$syncResult = SyncReturnValues::UPDATED;
}
try {
$this->emailHelper->sendWelcomeEmail($licensee, $club);
} catch (TransportExceptionInterface $transportException) {
$this->entityManager->rollback();

if (!$dbProfilePicture && $fftaProfilePicture instanceof LicenseeAttachment) {
$this->logger->notice(' + Adding profile picture');
$licensee->addAttachment($fftaProfilePicture);
$licensee->setUpdatedAt(new \DateTimeImmutable());
$this->entityManager->persist($fftaProfilePicture);
$syncResult = SyncReturnValues::UPDATED;
}
throw $transportException;
}

if (!$dbProfilePicture && !$fftaProfilePicture instanceof LicenseeAttachment) {
$this->logger->notice(' ! No profile picture');
}
$this->entityManager->commit();
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAndPersistNewLicensee() starts a DB transaction and calls commit()/rollback(), but it never flushes inside the transaction. As a result, the commit commits an empty transaction and the later flush() in syncLicenseeWithId() will write outside the transaction; additionally, on rollback the UnitOfWork still contains scheduled inserts (user/licensee/attachment) that could be flushed later. Use a proper transactional wrapper (e.g., EntityManager::wrapInTransaction) or explicitly flush() before commit(), and ensure the UnitOfWork is cleared/closed on rollback so the new entities can’t be persisted after a failed welcome email.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
17.0% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants