@the-bearded-bear/claude-craft 8.8.1 → 8.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dev/i18n/de/Angular/commands/check-compliance.md +218 -168
- package/Dev/i18n/de/Common/agents/refactoring-specialist.md +146 -69
- package/Dev/i18n/de/Common/commands/add-technology.md +166 -68
- package/Dev/i18n/de/Common/commands/setup-ci.md +216 -33
- package/Dev/i18n/de/Laravel/commands/check-compliance.md +223 -115
- package/Dev/i18n/de/Python/checklists/new-feature.md +319 -44
- package/Dev/i18n/de/React/rules/02-architecture.md +483 -322
- package/Dev/i18n/de/React/rules/03-coding-standards.md +584 -368
- package/Dev/i18n/de/Symfony/commands/check-compliance.md +186 -114
- package/Dev/i18n/de/Symfony/rules/07-testing-symfony.md +679 -10
- package/Dev/i18n/de/UIUX/commands/a11y-component.md +284 -26
- package/Dev/i18n/de/UIUX/commands/design-tokens.md +199 -35
- package/Dev/i18n/de/UIUX/commands/user-flow.md +179 -16
- package/Dev/i18n/de/VueJS/commands/check-compliance.md +227 -102
- package/Dev/i18n/es/Angular/commands/check-compliance.md +217 -167
- package/Dev/i18n/es/Common/commands/add-technology.md +158 -60
- package/Dev/i18n/es/Laravel/commands/check-compliance.md +223 -115
- package/Dev/i18n/es/React/commands/check-testing.md +263 -169
- package/Dev/i18n/es/ReactNative/commands/check-testing.md +256 -198
- package/Dev/i18n/es/Symfony/commands/check-compliance.md +189 -117
- package/Dev/i18n/es/Symfony/commands/check-testing.md +301 -102
- package/Dev/i18n/es/Symfony/commands/migration-plan.md +267 -34
- package/Dev/i18n/es/UIUX/commands/a11y-component.md +274 -16
- package/Dev/i18n/es/UIUX/commands/design-tokens.md +186 -22
- package/Dev/i18n/es/UIUX/commands/user-flow.md +173 -10
- package/Dev/i18n/es/VueJS/commands/check-compliance.md +227 -102
- package/Dev/i18n/fr/Angular/commands/check-compliance.md +217 -167
- package/Dev/i18n/fr/Common/commands/ralph-run.md +138 -60
- package/Dev/i18n/fr/Laravel/commands/check-compliance.md +223 -115
- package/Dev/i18n/fr/React/commands/check-architecture.md +370 -53
- package/Dev/i18n/fr/React/commands/check-code-quality.md +454 -64
- package/Dev/i18n/fr/React/commands/check-testing.md +476 -102
- package/Dev/i18n/fr/Symfony/commands/check-compliance.md +188 -116
- package/Dev/i18n/fr/VueJS/commands/check-compliance.md +227 -102
- package/Dev/i18n/pt/Angular/commands/check-compliance.md +225 -175
- package/Dev/i18n/pt/Common/agents/ralph-conductor.md +211 -30
- package/Dev/i18n/pt/Common/commands/add-technology.md +149 -51
- package/Dev/i18n/pt/Common/commands/ralph-run.md +239 -35
- package/Dev/i18n/pt/Flutter/commands/analyze-performance.md +331 -46
- package/Dev/i18n/pt/Flutter/commands/check-compliance.md +234 -29
- package/Dev/i18n/pt/Flutter/commands/generate-feature.md +526 -51
- package/Dev/i18n/pt/Flutter/commands/generate-widget.md +515 -27
- package/Dev/i18n/pt/Flutter/commands/golden-update.md +322 -46
- package/Dev/i18n/pt/Flutter/commands/localization-check.md +278 -37
- package/Dev/i18n/pt/Laravel/commands/check-compliance.md +212 -104
- package/Dev/i18n/pt/React/commands/accessibility-check.md +151 -42
- package/Dev/i18n/pt/React/commands/bundle-analyze.md +300 -25
- package/Dev/i18n/pt/React/commands/check-architecture.md +369 -34
- package/Dev/i18n/pt/React/commands/check-code-quality.md +440 -34
- package/Dev/i18n/pt/React/commands/check-compliance.md +232 -62
- package/Dev/i18n/pt/React/commands/check-security.md +370 -31
- package/Dev/i18n/pt/React/commands/check-testing.md +473 -43
- package/Dev/i18n/pt/React/commands/generate-component.md +454 -19
- package/Dev/i18n/pt/React/commands/generate-hook.md +425 -24
- package/Dev/i18n/pt/React/commands/storybook-story.md +520 -35
- package/Dev/i18n/pt/ReactNative/commands/app-size.md +358 -387
- package/Dev/i18n/pt/ReactNative/commands/check-code-quality.md +246 -75
- package/Dev/i18n/pt/ReactNative/commands/check-compliance.md +191 -85
- package/Dev/i18n/pt/ReactNative/commands/check-security.md +363 -115
- package/Dev/i18n/pt/ReactNative/commands/check-testing.md +269 -79
- package/Dev/i18n/pt/ReactNative/commands/generate-screen.md +491 -324
- package/Dev/i18n/pt/ReactNative/commands/native-module.md +539 -82
- package/Dev/i18n/pt/ReactNative/commands/store-prepare.md +429 -185
- package/Dev/i18n/pt/ReactNative/rules/02-architecture.md +1084 -31
- package/Dev/i18n/pt/Symfony/commands/check-compliance.md +195 -123
- package/Dev/i18n/pt/UIUX/commands/a11y-audit.md +208 -24
- package/Dev/i18n/pt/UIUX/commands/a11y-component.md +281 -23
- package/Dev/i18n/pt/UIUX/commands/design-tokens.md +197 -33
- package/Dev/i18n/pt/UIUX/commands/user-flow.md +183 -20
- package/Dev/i18n/pt/VueJS/commands/check-compliance.md +228 -103
- package/Dev/i18n/pt/Workflow/commands/analyze.md +147 -146
- package/Dev/i18n/pt/Workflow/commands/design.md +205 -204
- package/Dev/i18n/pt/Workflow/commands/implement.md +184 -184
- package/Project/i18n/de/Sprint/commands/dev.md +339 -86
- package/Project/i18n/es/Sprint/commands/dev.md +342 -91
- package/Project/i18n/pt/Sprint/commands/dev.md +343 -92
- package/bundles/cursor/.cursorrules +1 -1
- package/bundles/windsurf/.windsurfrules +1 -1
- package/package.json +1 -1
|
@@ -1,94 +1,421 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Vérification de la Qualité du Code
|
|
3
|
-
argument-hint: [arguments]
|
|
2
|
+
description: Vérification de la Qualité du Code
|
|
4
3
|
---
|
|
5
4
|
|
|
6
|
-
# Vérification de la Qualité du Code
|
|
5
|
+
# Vérification de la Qualité du Code
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Effectue une analyse complète de la qualité du code de l'application React.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
## Ce que fait cette commande
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
1. **Analyse de Qualité**
|
|
12
|
+
- Lancer le linting (ESLint)
|
|
13
|
+
- Vérification des types (TypeScript)
|
|
14
|
+
- Formatage du code (Prettier)
|
|
15
|
+
- Analyse de la complexité
|
|
16
|
+
- Détection des odeurs de code
|
|
17
|
+
- Vérification de la couverture de tests
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
2. **Métriques Mesurées**
|
|
20
|
+
- Complexité cyclomatique
|
|
21
|
+
- Duplication de code
|
|
22
|
+
- Couverture de tests
|
|
23
|
+
- Dette technique
|
|
24
|
+
- Indice de maintenabilité
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
3. **Rapport Généré**
|
|
27
|
+
- Score de qualité
|
|
28
|
+
- Problèmes par sévérité
|
|
29
|
+
- Recommandations de refactoring
|
|
30
|
+
- Tendances dans le temps
|
|
17
31
|
|
|
18
|
-
|
|
32
|
+
## Comment Utiliser
|
|
19
33
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- `/home/fmetivier/Documents/Company/TheBeardedCTO/Tools/Claude/Dev/React/rules/03-coding-standards.md`
|
|
24
|
-
- `/home/fmetivier/Documents/Company/TheBeardedCTO/Tools/Claude/Dev/React/rules/04-solid-principles.md`
|
|
25
|
-
- `/home/fmetivier/Documents/Company/TheBeardedCTO/Tools/Claude/Dev/React/rules/05-kiss-dry-yagni.md`
|
|
26
|
-
- `/home/fmetivier/Documents/Company/TheBeardedCTO/Tools/Claude/Dev/React/rules/08-quality-tools.md`
|
|
34
|
+
```bash
|
|
35
|
+
# Vérification complète de qualité
|
|
36
|
+
npm run quality
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
# Vérifications individuelles
|
|
39
|
+
npm run lint
|
|
40
|
+
npm run type-check
|
|
41
|
+
npm run format:check
|
|
42
|
+
npm run test:coverage
|
|
43
|
+
```
|
|
29
44
|
|
|
30
|
-
|
|
45
|
+
## Mode Plan
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
- [ ] tsconfig.json avec strict: true
|
|
34
|
-
- [ ] noImplicitAny, strictNullChecks activés
|
|
35
|
-
- [ ] Pas de @ts-ignore ou @ts-expect-error sans justification
|
|
36
|
-
- [ ] Types exportés depuis des fichiers .types.ts ou .d.ts
|
|
47
|
+
> Le mode plan est activé automatiquement lorsque le périmètre couvre plusieurs modules ou nécessite une investigation transversale.
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
- [ ] Props des composants typées avec interfaces
|
|
40
|
-
- [ ] Hooks personnalisés retournent des types explicites
|
|
41
|
-
- [ ] Pas d'usage excessif de 'any' (<5% des types)
|
|
42
|
-
- [ ] Types génériques utilisés correctement
|
|
43
|
-
- [ ] Enums ou union types pour les constantes
|
|
44
|
-
- [ ] Type guards pour les narrowing
|
|
45
|
-
- [ ] Discriminated unions pour les variants
|
|
49
|
+
## Vérifications de Qualité
|
|
46
50
|
|
|
47
|
-
###
|
|
51
|
+
### 1. Linting (ESLint)
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- [ ] Règles react-hooks activées
|
|
53
|
-
- [ ] Pas de violations non justifiées (eslint-disable)
|
|
53
|
+
```bash
|
|
54
|
+
# Vérifier les erreurs
|
|
55
|
+
npm run lint
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- [ ] Imports organisés (absolus vs relatifs)
|
|
59
|
-
- [ ] Pas de code mort ou commentaires inutiles
|
|
57
|
+
# Corriger automatiquement les erreurs
|
|
58
|
+
npm run lint:fix
|
|
59
|
+
```
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
**Configuration** :
|
|
62
|
+
```json
|
|
63
|
+
// .eslintrc.json
|
|
64
|
+
{
|
|
65
|
+
"extends": [
|
|
66
|
+
"eslint:recommended",
|
|
67
|
+
"plugin:@typescript-eslint/recommended",
|
|
68
|
+
"plugin:react/recommended",
|
|
69
|
+
"plugin:react-hooks/recommended"
|
|
70
|
+
],
|
|
71
|
+
"rules": {
|
|
72
|
+
"no-console": "warn",
|
|
73
|
+
"no-debugger": "error",
|
|
74
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
75
|
+
"react-hooks/rules-of-hooks": "error",
|
|
76
|
+
"react-hooks/exhaustive-deps": "warn"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
62
80
|
|
|
63
|
-
|
|
64
|
-
- [ ] PascalCase pour les composants React
|
|
65
|
-
- [ ] camelCase pour les fonctions utilitaires
|
|
66
|
-
- [ ] UPPER_CASE pour les constantes
|
|
67
|
-
- [ ] Noms descriptifs et auto-documentés
|
|
68
|
-
- [ ] Préfixes cohérents (use pour hooks, is/has pour booléens)
|
|
81
|
+
### 2. Vérification des Types (TypeScript)
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
```bash
|
|
84
|
+
# Vérifier les types
|
|
85
|
+
npm run type-check
|
|
71
86
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- Vérifier la composition vs l'héritage
|
|
76
|
-
- Analyser le couplage et la cohésion
|
|
77
|
-
- Vérifier DRY (pas de duplication de code)
|
|
78
|
-
- Vérifier KISS (simplicité des solutions)
|
|
87
|
+
# Mode watch
|
|
88
|
+
npm run type-check:watch
|
|
89
|
+
```
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
**Configuration TypeScript** :
|
|
81
92
|
|
|
82
93
|
**Score sur 25 points :**
|
|
83
|
-
- Configuration TypeScript : 6 points
|
|
84
|
-
- Qualité du typage : 7 points
|
|
94
|
+
- Configuration TypeScript : 6 points (tsconfig strict, noImplicitAny, strictNullChecks)
|
|
95
|
+
- Qualité du typage : 7 points (interfaces, génériques, discriminated unions)
|
|
85
96
|
- Configuration ESLint : 4 points
|
|
86
97
|
- Code style : 4 points
|
|
87
98
|
- Conventions de nommage : 4 points
|
|
88
99
|
|
|
89
|
-
|
|
100
|
+
**Problèmes Courants** :
|
|
101
|
+
```typescript
|
|
102
|
+
// ❌ Mauvais - Type any
|
|
103
|
+
const data: any = fetchData();
|
|
104
|
+
|
|
105
|
+
// ✅ Bon - Types appropriés
|
|
106
|
+
interface User {
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
}
|
|
110
|
+
const data: User = fetchData();
|
|
111
|
+
|
|
112
|
+
// ❌ Mauvais - any implicite
|
|
113
|
+
const handleClick = (event) => {};
|
|
114
|
+
|
|
115
|
+
// ✅ Bon - Types explicites
|
|
116
|
+
const handleClick = (event: React.MouseEvent) => {};
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 3. Formatage du Code (Prettier)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Vérifier le formatage
|
|
123
|
+
npm run format:check
|
|
124
|
+
|
|
125
|
+
# Formater tous les fichiers
|
|
126
|
+
npm run format
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Configuration** :
|
|
130
|
+
```json
|
|
131
|
+
// .prettierrc
|
|
132
|
+
{
|
|
133
|
+
"semi": true,
|
|
134
|
+
"trailingComma": "all",
|
|
135
|
+
"singleQuote": true,
|
|
136
|
+
"printWidth": 100,
|
|
137
|
+
"tabWidth": 2
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 4. Analyse de Complexité
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// ❌ Mauvais - Complexité élevée (10+)
|
|
145
|
+
function processUser(user, options) {
|
|
146
|
+
if (user.isActive) {
|
|
147
|
+
if (user.role === 'admin') {
|
|
148
|
+
if (options.includeStats) {
|
|
149
|
+
if (user.lastLogin) {
|
|
150
|
+
// ... logique imbriquée
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Complexité : 15
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ✅ Bon - Faible complexité
|
|
159
|
+
function processUser(user, options) {
|
|
160
|
+
if (!user.isActive) return null;
|
|
161
|
+
if (user.role !== 'admin') return formatBasicUser(user);
|
|
162
|
+
if (!options.includeStats) return formatAdminUser(user);
|
|
163
|
+
return formatAdminUserWithStats(user);
|
|
164
|
+
// Complexité : 4
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 5. Duplication de Code
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// ❌ Mauvais - Code dupliqué
|
|
172
|
+
export const UserList = () => {
|
|
173
|
+
const [users, setUsers] = useState([]);
|
|
174
|
+
const [loading, setLoading] = useState(false);
|
|
175
|
+
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
setLoading(true);
|
|
178
|
+
fetch('/api/users')
|
|
179
|
+
.then(res => res.json())
|
|
180
|
+
.then(setUsers)
|
|
181
|
+
.finally(() => setLoading(false));
|
|
182
|
+
}, []);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const ProductList = () => {
|
|
186
|
+
const [products, setProducts] = useState([]);
|
|
187
|
+
const [loading, setLoading] = useState(false);
|
|
188
|
+
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
setLoading(true);
|
|
191
|
+
fetch('/api/products')
|
|
192
|
+
.then(res => res.json())
|
|
193
|
+
.then(setProducts)
|
|
194
|
+
.finally(() => setLoading(false));
|
|
195
|
+
}, []);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// ✅ Bon - Hook réutilisable
|
|
199
|
+
export const useFetch = <T>(url: string) => {
|
|
200
|
+
const [data, setData] = useState<T[]>([]);
|
|
201
|
+
const [loading, setLoading] = useState(false);
|
|
202
|
+
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
setLoading(true);
|
|
205
|
+
fetch(url)
|
|
206
|
+
.then(res => res.json())
|
|
207
|
+
.then(setData)
|
|
208
|
+
.finally(() => setLoading(false));
|
|
209
|
+
}, [url]);
|
|
210
|
+
|
|
211
|
+
return { data, loading };
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Métriques de Qualité du Code
|
|
216
|
+
|
|
217
|
+
### Complexité Cyclomatique
|
|
218
|
+
|
|
219
|
+
**Objectif** : < 10 par fonction
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Installer le vérificateur de complexité
|
|
223
|
+
npm install -D eslint-plugin-complexity
|
|
224
|
+
|
|
225
|
+
# Ajouter à la config ESLint
|
|
226
|
+
{
|
|
227
|
+
"rules": {
|
|
228
|
+
"complexity": ["error", 10]
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Couverture de Tests
|
|
234
|
+
|
|
235
|
+
**Objectifs** :
|
|
236
|
+
- Lignes : > 80%
|
|
237
|
+
- Fonctions : > 80%
|
|
238
|
+
- Branches : > 75%
|
|
239
|
+
- Instructions : > 80%
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Générer le rapport de couverture
|
|
243
|
+
npm run test:coverage
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
```json
|
|
247
|
+
// vitest.config.ts
|
|
248
|
+
export default defineConfig({
|
|
249
|
+
test: {
|
|
250
|
+
coverage: {
|
|
251
|
+
provider: 'v8',
|
|
252
|
+
reporter: ['text', 'json', 'html'],
|
|
253
|
+
lines: 80,
|
|
254
|
+
functions: 80,
|
|
255
|
+
branches: 75,
|
|
256
|
+
statements: 80
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Duplication de Code
|
|
263
|
+
|
|
264
|
+
**Objectif** : < 3% de duplication
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# Installer jscpd
|
|
268
|
+
npm install -D jscpd
|
|
90
269
|
|
|
91
|
-
|
|
270
|
+
# Lancer la vérification de duplication
|
|
271
|
+
npx jscpd src/
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Portes de Qualité
|
|
275
|
+
|
|
276
|
+
### Vérifications Pré-Commit
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
// package.json
|
|
280
|
+
{
|
|
281
|
+
"lint-staged": {
|
|
282
|
+
"*.{ts,tsx}": [
|
|
283
|
+
"eslint --fix",
|
|
284
|
+
"prettier --write",
|
|
285
|
+
"vitest related --run --passWithNoTests"
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Portes de Qualité CI/CD
|
|
292
|
+
|
|
293
|
+
```yaml
|
|
294
|
+
# .github/workflows/quality.yml
|
|
295
|
+
name: Quality Check
|
|
296
|
+
|
|
297
|
+
on: [pull_request]
|
|
298
|
+
|
|
299
|
+
jobs:
|
|
300
|
+
quality:
|
|
301
|
+
runs-on: ubuntu-latest
|
|
302
|
+
steps:
|
|
303
|
+
- uses: actions/checkout@v3
|
|
304
|
+
- uses: actions/setup-node@v3
|
|
305
|
+
|
|
306
|
+
- name: Install dependencies
|
|
307
|
+
run: npm ci
|
|
308
|
+
|
|
309
|
+
- name: Lint
|
|
310
|
+
run: npm run lint
|
|
311
|
+
|
|
312
|
+
- name: Type check
|
|
313
|
+
run: npm run type-check
|
|
314
|
+
|
|
315
|
+
- name: Format check
|
|
316
|
+
run: npm run format:check
|
|
317
|
+
|
|
318
|
+
- name: Test with coverage
|
|
319
|
+
run: npm run test:coverage
|
|
320
|
+
|
|
321
|
+
- name: Check coverage
|
|
322
|
+
uses: codecov/codecov-action@v3
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Odeurs de Code
|
|
326
|
+
|
|
327
|
+
### 1. Longues Listes de Paramètres
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// ❌ Mauvais - Trop de paramètres
|
|
331
|
+
function createUser(
|
|
332
|
+
name: string,
|
|
333
|
+
email: string,
|
|
334
|
+
age: number,
|
|
335
|
+
address: string,
|
|
336
|
+
phone: string,
|
|
337
|
+
role: string
|
|
338
|
+
) {}
|
|
339
|
+
|
|
340
|
+
// ✅ Bon - Utiliser un paramètre objet
|
|
341
|
+
interface CreateUserParams {
|
|
342
|
+
name: string;
|
|
343
|
+
email: string;
|
|
344
|
+
age: number;
|
|
345
|
+
address: string;
|
|
346
|
+
phone: string;
|
|
347
|
+
role: string;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function createUser(params: CreateUserParams) {}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### 2. Grandes Fonctions
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// ❌ Mauvais - Fonction trop longue (100+ lignes)
|
|
357
|
+
function handleSubmit() {
|
|
358
|
+
// ... 100 lignes de code
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// ✅ Bon - Décomposer en fonctions plus petites
|
|
362
|
+
function handleSubmit() {
|
|
363
|
+
validateForm();
|
|
364
|
+
processData();
|
|
365
|
+
submitToAPI();
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### 3. Nombres Magiques
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
// ❌ Mauvais - Nombres magiques
|
|
373
|
+
if (user.age > 18 && cart.total > 100) {}
|
|
374
|
+
|
|
375
|
+
// ✅ Bon - Constantes nommées
|
|
376
|
+
const ADULT_AGE = 18;
|
|
377
|
+
const FREE_SHIPPING_THRESHOLD = 100;
|
|
378
|
+
|
|
379
|
+
if (user.age > ADULT_AGE && cart.total > FREE_SHIPPING_THRESHOLD) {}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### 4. Imbrication Profonde
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
// ❌ Mauvais - Imbrication profonde
|
|
386
|
+
if (user) {
|
|
387
|
+
if (user.isActive) {
|
|
388
|
+
if (user.role === 'admin') {
|
|
389
|
+
if (hasPermission) {
|
|
390
|
+
// ...
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// ✅ Bon - Guard clauses
|
|
397
|
+
if (!user) return;
|
|
398
|
+
if (!user.isActive) return;
|
|
399
|
+
if (user.role !== 'admin') return;
|
|
400
|
+
if (!hasPermission) return;
|
|
401
|
+
// ...
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Intégration SonarQube
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Installer SonarScanner
|
|
408
|
+
npm install -D sonarqube-scanner
|
|
409
|
+
|
|
410
|
+
# Lancer l'analyse
|
|
411
|
+
npx sonar-scanner \
|
|
412
|
+
-Dsonar.projectKey=my-project \
|
|
413
|
+
-Dsonar.sources=src \
|
|
414
|
+
-Dsonar.host.url=http://localhost:9000 \
|
|
415
|
+
-Dsonar.login=your-token
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## Rapport de Conformité
|
|
92
419
|
|
|
93
420
|
```
|
|
94
421
|
═══════════════════════════════════════════════════
|
|
@@ -165,12 +492,75 @@ Exemples de violations :
|
|
|
165
492
|
• rules/08-quality-tools.md - Outils de qualité
|
|
166
493
|
```
|
|
167
494
|
|
|
168
|
-
|
|
495
|
+
## Amélioration Continue
|
|
496
|
+
|
|
497
|
+
### Suivi des Métriques dans le Temps
|
|
498
|
+
|
|
499
|
+
```json
|
|
500
|
+
// .qualityrc
|
|
501
|
+
{
|
|
502
|
+
"metrics": {
|
|
503
|
+
"complexity": {
|
|
504
|
+
"current": 8,
|
|
505
|
+
"target": 10,
|
|
506
|
+
"trend": "improving"
|
|
507
|
+
},
|
|
508
|
+
"coverage": {
|
|
509
|
+
"current": 85,
|
|
510
|
+
"target": 80,
|
|
511
|
+
"trend": "stable"
|
|
512
|
+
},
|
|
513
|
+
"duplication": {
|
|
514
|
+
"current": 2,
|
|
515
|
+
"target": 3,
|
|
516
|
+
"trend": "improving"
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Tableau de Bord Qualité
|
|
523
|
+
|
|
524
|
+
Créer un tableau de bord pour visualiser :
|
|
525
|
+
- Tendances de la couverture de code
|
|
526
|
+
- Tendances de la complexité
|
|
527
|
+
- Nombre de problèmes par sévérité
|
|
528
|
+
- Estimation de la dette technique
|
|
529
|
+
|
|
530
|
+
## Métriques de Qualité Calculées
|
|
169
531
|
|
|
170
532
|
Calculer et afficher :
|
|
171
533
|
- Pourcentage de fichiers avec strict mode TypeScript
|
|
172
|
-
- Nombre de any détectés vs types explicites
|
|
534
|
+
- Nombre de `any` détectés vs types explicites
|
|
173
535
|
- Taux de conformité ESLint
|
|
174
536
|
- Nombre de fichiers non formatés par Prettier
|
|
175
537
|
- Complexité cyclomatique moyenne
|
|
176
538
|
- Dette technique estimée (en heures de refactoring)
|
|
539
|
+
|
|
540
|
+
## Outils
|
|
541
|
+
|
|
542
|
+
- **ESLint** : Linting du code
|
|
543
|
+
- **TypeScript** : Vérification des types
|
|
544
|
+
- **Prettier** : Formatage du code
|
|
545
|
+
- **Vitest** : Couverture de tests
|
|
546
|
+
- **SonarQube** : Plateforme de qualité du code
|
|
547
|
+
- **jscpd** : Détection de duplication
|
|
548
|
+
- **Lighthouse** : Audit de performance
|
|
549
|
+
|
|
550
|
+
## Bonnes Pratiques
|
|
551
|
+
|
|
552
|
+
1. **Lancer les vérifications localement** avant de pousser
|
|
553
|
+
2. **Automatiser en CI/CD** pour appliquer les standards
|
|
554
|
+
3. **Définir des portes de qualité** qui doivent passer
|
|
555
|
+
4. **Surveiller les tendances** dans le temps
|
|
556
|
+
5. **Refactoriser régulièrement** pour réduire la dette technique
|
|
557
|
+
6. **Documenter les standards** pour l'équipe
|
|
558
|
+
7. **Revoir les métriques** en réunion d'équipe
|
|
559
|
+
8. **Célébrer les améliorations**
|
|
560
|
+
|
|
561
|
+
## Ressources
|
|
562
|
+
|
|
563
|
+
- [ESLint Rules](https://eslint.org/docs/rules/)
|
|
564
|
+
- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html)
|
|
565
|
+
- [Clean Code Principles](https://github.com/ryanmcdermott/clean-code-javascript)
|
|
566
|
+
- [Refactoring Guru](https://refactoring.guru/)
|