---
description: Phase 8 - Review Pull Request with checklist and suggestions
agent: gitflow-review
model: haiku
---

# Phase 8: REVIEW - Review PR avec checklist

Tu es expert code review .NET/EF Core. Analyse la PR et fournis feedback structure.

**Argument:** `$ARGUMENTS` = numero PR ou URL (requis)

---

## Detection du provider

```bash
REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "")

if [[ "$REMOTE_URL" == *"dev.azure.com"* ]] || [[ "$REMOTE_URL" == *"visualstudio.com"* ]]; then
  GIT_PROVIDER="azuredevops"
  if [[ "$REMOTE_URL" =~ dev\.azure\.com/([^/]+)/([^/]+)/_git/([^/]+) ]]; then
    AZURE_ORG="${BASH_REMATCH[1]}"
    AZURE_PROJECT="${BASH_REMATCH[2]}"
    AZURE_REPO="${BASH_REMATCH[3]}"
  fi
elif [[ "$REMOTE_URL" == *"github.com"* ]]; then
  GIT_PROVIDER="github"
else
  GIT_PROVIDER="unknown"
fi
```

---

## Chargement PR

```bash
if [ "$GIT_PROVIDER" = "azuredevops" ]; then
  # Recuperer infos PR Azure DevOps
  az repos pr show --id {number} \
    --organization "https://dev.azure.com/$AZURE_ORG" \
    --project "$AZURE_PROJECT"

  # Recuperer les fichiers changes
  az repos pr diff --id {number} \
    --organization "https://dev.azure.com/$AZURE_ORG" \
    --project "$AZURE_PROJECT"
else
  # Recuperer infos PR GitHub
  gh pr view {number} --json title,body,files,commits,reviews,checks

  # Recuperer diff
  gh pr diff {number}
fi
```

---

## Checklist Review

### 1. Code Quality

| Check | Critere | Poids |
|-------|---------|-------|
| Lisibilite | Noms clairs, structure logique | HIGH |
| DRY | Pas de duplication | MEDIUM |
| SOLID | Principes respectes | MEDIUM |
| Complexite | Methodes < 20 lignes, cyclomatic < 10 | LOW |

### 2. Patterns .NET

| Check | Validation |
|-------|------------|
| Async/Await | Pas de `.Result` ou `.Wait()` |
| Dependency Injection | Pas de `new Service()` |
| Null handling | `?.` ou `??` ou `required` |
| Exceptions | Specifiques, pas `catch (Exception)` |

### 3. EF Core (si migrations)

| Check | Validation | Severite |
|-------|------------|----------|
| 3 fichiers | Migration + Designer + ModelSnapshot | BLOQUANT |
| Naming | Convention `{Date}_{Description}` | WARNING |
| Down() | Methode Down implementee | WARNING |
| Indexes | Sur colonnes FK et filtres frequents | INFO |
| Data loss | Pas de DropColumn sans backup | BLOQUANT |

### 4. Tests

| Check | Critere |
|-------|---------|
| Coverage | Nouveau code couvert |
| Naming | `{Method}_Should_{Behavior}_When_{Condition}` |
| Arrange/Act/Assert | Structure claire |
| Mocks | Pas de dependances reelles |

### 5. Security

| Check | Pattern a detecter | Severite |
|-------|-------------------|----------|
| Secrets | `password`, `apikey`, `secret` hardcodes | BLOQUANT |
| SQL Injection | String concat dans queries | BLOQUANT |
| XSS | `@Html.Raw()` sans sanitization | HIGH |
| Auth | `[AllowAnonymous]` sur endpoints sensibles | HIGH |

---

## Analyse automatique

### Fichiers a examiner en priorite

| Priorite | Type | Raison |
|----------|------|--------|
| 1 | `*Migration*.cs` | Impact base de donnees |
| 2 | `*Controller*.cs` | Surface d'attaque |
| 3 | `*Service*.cs` | Logique metier |
| 4 | `*.razor` | UI et securite XSS |
| 5 | Tests | Qualite couverture |

### Metriques

```
METRIQUES PR
────────────────────────────────
Fichiers:    {count} (+{added}/-{removed})
Commits:     {count}
Insertions:  +{lines}
Deletions:   -{lines}

Ratio tests: {test_files}/{total_files}
────────────────────────────────
```

---

## Output Review

### Format

```
CODE REVIEW - PR #{number}
════════════════════════════════════════

RESUME: {APPROVE | CHANGES_REQUESTED | COMMENT}

BLOQUANTS ({count}):
🔴 [{file}:{line}] {description}
   Suggestion: {fix}

WARNINGS ({count}):
🟡 [{file}:{line}] {description}
   Suggestion: {fix}

SUGGESTIONS ({count}):
🟢 [{file}:{line}] {description}

POINTS POSITIFS:
✨ {ce qui est bien fait}

════════════════════════════════════════
```

### Soumission review

#### GitHub

```bash
if [ "$GIT_PROVIDER" = "github" ]; then
  # Approve
  gh pr review {number} --approve --body "{comments}"

  # Request changes
  gh pr review {number} --request-changes --body "{comments}"

  # Comment only
  gh pr review {number} --comment --body "{comments}"
fi
```

#### Azure DevOps

```bash
if [ "$GIT_PROVIDER" = "azuredevops" ]; then
  # Azure DevOps utilise un systeme de vote:
  # 10 = Approved, 5 = Approved with suggestions, 0 = No vote, -5 = Waiting, -10 = Rejected

  # Approve
  az repos pr set-vote --id {number} --vote approve \
    --organization "https://dev.azure.com/$AZURE_ORG" \
    --project "$AZURE_PROJECT"

  # Request changes (reject)
  az repos pr set-vote --id {number} --vote reject \
    --organization "https://dev.azure.com/$AZURE_ORG" \
    --project "$AZURE_PROJECT"

  # Ajouter commentaire
  az repos pr comment create --id {number} \
    --content "{comments}" \
    --organization "https://dev.azure.com/$AZURE_ORG" \
    --project "$AZURE_PROJECT"
fi
```

> **Note Azure DevOps:** Les votes possibles sont: `approve`, `approve-with-suggestions`, `reset`, `wait-for-author`, `reject`

---

## Resume

```
REVIEW COMPLETE
────────────────────────────────
PR:       #{number}
Status:   {APPROVED|CHANGES_REQUESTED|COMMENTED}

Issues:
  Bloquants:   {count}
  Warnings:    {count}
  Suggestions: {count}

EF Core: {OK|ISSUES|N/A}
Tests:   {COVERED|MISSING|N/A}
Security: {OK|ISSUES}
────────────────────────────────
Prochain: /gitflow:9-merge #{number}
```

---

## Modes

| Commande | Action |
|----------|--------|
| `/gitflow:8-review 123` | Review PR #123 |
| `/gitflow:8-review --security` | Focus securite |
| `/gitflow:8-review --ef-core` | Focus migrations |
| `/gitflow:8-review --quick` | Checklist rapide |
