wip(06-sonarqube-quality): 6 planów SonarQube Quality utworzonych
Plany dla php:S112, S1142, S1192, S3776, S1448, S138 — gotowe do APPLY. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
231
.paul/phases/06-sonarqube-quality/06-03-PLAN.md
Normal file
231
.paul/phases/06-sonarqube-quality/06-03-PLAN.md
Normal file
@@ -0,0 +1,231 @@
|
||||
---
|
||||
phase: 06-sonarqube-quality
|
||||
plan: 03
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- src/Core/Constants/IntegrationSources.php
|
||||
- src/Core/Constants/RedirectPaths.php
|
||||
- src/Modules/Settings/AllegroIntegrationController.php
|
||||
- src/Modules/Settings/ShopproIntegrationsController.php
|
||||
- src/Modules/Orders/OrdersRepository.php
|
||||
- src/Modules/Settings/AllegroOrdersSyncService.php
|
||||
- src/Modules/Settings/AllegroStatusSyncService.php
|
||||
- src/Modules/Settings/AllegroOrderImportService.php
|
||||
- src/Modules/Settings/ShopproOrdersSyncService.php
|
||||
- src/Modules/Settings/ShopproStatusSyncService.php
|
||||
- src/Modules/Settings/ShopproPaymentStatusSyncService.php
|
||||
autonomous: true
|
||||
---
|
||||
|
||||
<objective>
|
||||
## Goal
|
||||
Wyciągnąć 40+ powtarzających się literałów string do stałych — eliminacja naruszeń SonarQube php:S1192.
|
||||
|
||||
## Purpose
|
||||
Ciągi jak `'allegro'` (23x), `'shoppro'` (15x), redirect paths (5-6x) i identyfikatory statusów rozsiane po całym kodzie to pułapki na literówki i utrudnienie przy refaktoryzacji. Stałe zapewniają jedno miejsce zmiany i wykrycie błędu przez IDE.
|
||||
|
||||
## Output
|
||||
Dwie klasy stałych w `src/Core/Constants/`, wszystkie powtórzenia zastąpione — S1192 spada z 40 do ~5.
|
||||
</objective>
|
||||
|
||||
<context>
|
||||
## Project Context
|
||||
@.paul/PROJECT.md
|
||||
|
||||
## Source Files
|
||||
@src/Modules/Orders/OrdersRepository.php
|
||||
@src/Modules/Settings/AllegroIntegrationController.php
|
||||
@src/Modules/Settings/ShopproIntegrationsController.php
|
||||
</context>
|
||||
|
||||
<skills>
|
||||
## Required Skills (from SPECIAL-FLOWS.md)
|
||||
|
||||
| Skill | Priority | When to Invoke | Loaded? |
|
||||
|-------|----------|----------------|---------|
|
||||
| sonar-scanner | required | Po APPLY, przed UNIFY | ○ |
|
||||
|
||||
## Skill Invocation Checklist
|
||||
- [ ] sonar-scanner uruchomiony po zakończeniu APPLY
|
||||
</skills>
|
||||
|
||||
<acceptance_criteria>
|
||||
|
||||
## AC-1: Klasy stałych istnieją
|
||||
```gherkin
|
||||
Given brak src/Core/Constants/
|
||||
When plan zostaje wykonany
|
||||
Then src/Core/Constants/IntegrationSources.php zawiera ALLEGRO, SHOPPRO, APACZKA, INPOST
|
||||
src/Core/Constants/RedirectPaths.php zawiera stałe dla ścieżek integracji
|
||||
```
|
||||
|
||||
## AC-2: Identyfikatory źródeł podmienione
|
||||
```gherkin
|
||||
Given 'allegro' (23x), 'shoppro' (15x), 'apaczka' (10x), 'inpost' (7x) rozsiane w src/
|
||||
When plan zostaje wykonany
|
||||
Then wszystkie wystąpienia w plikach PHP (poza SQL query strings) używają IntegrationSources::ALLEGRO etc.
|
||||
```
|
||||
|
||||
## AC-3: Redirect paths podmienione w kontrolerach
|
||||
```gherkin
|
||||
Given '/settings/integrations/allegro' (5x), '/settings/integrations/shoppro' (6x) w kontrolerach
|
||||
When plan zostaje wykonany
|
||||
Then AllegroIntegrationController i ShopproIntegrationsController używają RedirectPaths::*
|
||||
```
|
||||
|
||||
## AC-4: Brak regresji
|
||||
```gherkin
|
||||
Given aplikacja działa z twardymi stringami
|
||||
When stałe mają identyczne wartości co podmienianie literały
|
||||
Then zachowanie aplikacji identyczne — routing, source matching, redirect paths
|
||||
```
|
||||
|
||||
</acceptance_criteria>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Utwórz klasy stałych IntegrationSources i RedirectPaths</name>
|
||||
<files>
|
||||
src/Core/Constants/IntegrationSources.php,
|
||||
src/Core/Constants/RedirectPaths.php
|
||||
</files>
|
||||
<action>
|
||||
Utwórz folder src/Core/Constants/ i dwa pliki:
|
||||
|
||||
**IntegrationSources.php** (namespace App\Core\Constants):
|
||||
```php
|
||||
final class IntegrationSources {
|
||||
public const ALLEGRO = 'allegro';
|
||||
public const SHOPPRO = 'shoppro';
|
||||
public const APACZKA = 'apaczka';
|
||||
public const INPOST = 'inpost';
|
||||
}
|
||||
```
|
||||
|
||||
**RedirectPaths.php** (namespace App\Core\Constants):
|
||||
Przejrzyj AllegroIntegrationController i ShopproIntegrationsController i wypisz wszystkie unikalne redirect paths (np. '/settings/integrations/allegro', '/settings/integrations/allegro?tab=settings', '/settings/integrations/shoppro', etc.).
|
||||
Utwórz stałe dla każdego unikalnego path:
|
||||
```php
|
||||
final class RedirectPaths {
|
||||
public const ALLEGRO_INTEGRATION = '/settings/integrations/allegro';
|
||||
public const ALLEGRO_SETTINGS_TAB = '/settings/integrations/allegro?tab=settings';
|
||||
public const ALLEGRO_STATUS_MAPPING_TAB = '/settings/integrations/allegro?tab=status-mapping';
|
||||
public const ALLEGRO_DELIVERY_TAB = '/settings/integrations/allegro?tab=delivery-mapping';
|
||||
public const SHOPPRO_INTEGRATION = '/settings/integrations/shoppro';
|
||||
public const SHOPPRO_SETTINGS_TAB = '/settings/integrations/shoppro?tab=settings';
|
||||
// ... dodaj wszystkie które znajdziesz w plikach kontrolerów
|
||||
}
|
||||
```
|
||||
|
||||
Klasy final, bez konstruktora, bez metod — tylko stałe.
|
||||
</action>
|
||||
<verify>
|
||||
php -l src/Core/Constants/IntegrationSources.php
|
||||
php -l src/Core/Constants/RedirectPaths.php
|
||||
</verify>
|
||||
<done>AC-1 satisfied: oba pliki istnieją, poprawna składnia PHP</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Podmień identyfikatory źródeł w Services i Repositories</name>
|
||||
<files>
|
||||
src/Modules/Settings/AllegroOrdersSyncService.php,
|
||||
src/Modules/Settings/AllegroStatusSyncService.php,
|
||||
src/Modules/Settings/AllegroOrderImportService.php,
|
||||
src/Modules/Settings/ShopproOrdersSyncService.php,
|
||||
src/Modules/Settings/ShopproStatusSyncService.php,
|
||||
src/Modules/Settings/ShopproPaymentStatusSyncService.php,
|
||||
src/Modules/Orders/OrdersRepository.php
|
||||
</files>
|
||||
<action>
|
||||
W każdym pliku:
|
||||
1. Dodaj use App\Core\Constants\IntegrationSources; na górze
|
||||
2. Podmień literały:
|
||||
- 'allegro' (gdy to identyfikator źródła/integracji, NIE gdy nazwa tabeli SQL) → IntegrationSources::ALLEGRO
|
||||
- 'shoppro' → IntegrationSources::SHOPPRO
|
||||
- 'apaczka' → IntegrationSources::APACZKA
|
||||
- 'inpost' → IntegrationSources::INPOST
|
||||
|
||||
WAŻNE — co NIE podmieniać:
|
||||
- String w zapytaniach SQL (np. WHERE source = 'allegro' w OrdersRepository) — zostaw literal (SonarQube wyjątek dla SQL)
|
||||
- Nazwy tabel, kolumn — zostaw
|
||||
- Klucze tłumaczeń (np. 'settings.allegro.*') — zostaw
|
||||
- Redirect URL paths — podmieniane w Task 3
|
||||
|
||||
Sprawdź kontekst każdego wystąpienia przed podmianą.
|
||||
</action>
|
||||
<verify>
|
||||
php -l na każdym zmodyfikowanym pliku
|
||||
grep -n "'allegro'" src/Modules/Settings/AllegroOrdersSyncService.php — 0 wyników (lub tylko w SQL/komentarzach)
|
||||
grep -n "'shoppro'" src/Modules/Settings/ShopproOrdersSyncService.php — 0 wyników (lub tylko w SQL/komentarzach)
|
||||
</verify>
|
||||
<done>AC-2 satisfied: identyfikatory źródeł w services/repositories używają IntegrationSources::*</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Podmień redirect paths i source literals w kontrolerach</name>
|
||||
<files>
|
||||
src/Modules/Settings/AllegroIntegrationController.php,
|
||||
src/Modules/Settings/ShopproIntegrationsController.php
|
||||
</files>
|
||||
<action>
|
||||
W obu plikach:
|
||||
1. Dodaj use App\Core\Constants\IntegrationSources;
|
||||
2. Dodaj use App\Core\Constants\RedirectPaths;
|
||||
3. Podmień redirect path strings → odpowiednie RedirectPaths::*
|
||||
4. Podmień identyfikatory źródeł 'allegro', 'shoppro' → IntegrationSources::*
|
||||
|
||||
Szczególna uwaga:
|
||||
- Header redirect strings (np. header('Location: /settings/integrations/allegro')) → RedirectPaths::ALLEGRO_INTEGRATION
|
||||
- URL z tabami → odpowiednie stałe z RedirectPaths
|
||||
- Nie podmieniaj kluczy tłumaczeń (settings.allegro.*)
|
||||
- Nie podmieniaj niczego w widokach (resources/views/)
|
||||
</action>
|
||||
<verify>
|
||||
php -l src/Modules/Settings/AllegroIntegrationController.php
|
||||
php -l src/Modules/Settings/ShopproIntegrationsController.php
|
||||
grep -c "'/settings/integrations/allegro'" src/Modules/Settings/AllegroIntegrationController.php — 0
|
||||
grep -c "'/settings/integrations/shoppro'" src/Modules/Settings/ShopproIntegrationsController.php — 0
|
||||
</verify>
|
||||
<done>AC-3, AC-4 satisfied: redirect paths podmienione; aplikacja zachowuje identyczne zachowanie</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<boundaries>
|
||||
|
||||
## DO NOT CHANGE
|
||||
- Zapytania SQL z literałami (np. 'allegro' w WHERE clauses) — SonarQube nie flaguje string w SQL
|
||||
- Klucze tłumaczeń (settings.allegro.*, settings.integrations.*)
|
||||
- Pliki widoków (resources/views/)
|
||||
- routes/web.php
|
||||
- Nazwy tabel i kolumn w SQL
|
||||
|
||||
## SCOPE LIMITS
|
||||
- Tylko pliki wymienione w files_modified
|
||||
- Nie tworzyć stałych dla string które pojawiają się tylko 1-2 razy (SonarQube S1192 flaguje 3+ powtórzenia)
|
||||
- Nie przenosić stałych do modułów — zostają w Core/Constants (globalne identyfikatory)
|
||||
|
||||
</boundaries>
|
||||
|
||||
<verification>
|
||||
Przed zamknięciem planu:
|
||||
- [ ] php -l na wszystkich zmodyfikowanych plikach — zero błędów
|
||||
- [ ] ls src/Core/Constants/ — IntegrationSources.php, RedirectPaths.php
|
||||
- [ ] grep -rn "'allegro'" src/ (bez SQL context) — drastycznie zredukowane
|
||||
- [ ] grep -rn "'shoppro'" src/ (bez SQL context) — drastycznie zredukowane
|
||||
- [ ] sonar-scanner — S1192 violations zmalały
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Oba pliki Constants istnieją i są poprawne składniowo
|
||||
- Wszystkie zmodyfikowane pliki bez błędów PHP
|
||||
- SonarQube S1192 spada z 40 do ≤10
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
Po zakończeniu utwórz `.paul/phases/06-sonarqube-quality/06-03-SUMMARY.md`
|
||||
</output>
|
||||
Reference in New Issue
Block a user