react-code-smell-detector 1.5.1 โ 1.5.3
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/README.md +389 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A CLI tool that analyzes React projects and detects common code smells, providin
|
|
|
7
7
|
- ๐ **Detect Code Smells**: Identifies common React anti-patterns (70+ smell types)
|
|
8
8
|
- ๐ **Technical Debt Score**: Grades your codebase from A to F
|
|
9
9
|
- ๐ก **Refactoring Suggestions**: Actionable recommendations for each issue
|
|
10
|
-
- ๐ **Multiple Output Formats**: Console (colored), JSON, Markdown, and
|
|
10
|
+
- ๐ **Multiple Output Formats**: Console (colored), JSON, Markdown, HTML, and PDF
|
|
11
11
|
- ๐ **Security Scanning**: Detects XSS vulnerabilities, eval usage, exposed secrets
|
|
12
12
|
- โฟ **Accessibility Checks**: Missing alt text, labels, ARIA attributes
|
|
13
13
|
- ๐ **Debug Cleanup**: console.log, debugger, TODO/FIXME detection
|
|
@@ -19,7 +19,7 @@ A CLI tool that analyzes React projects and detects common code smells, providin
|
|
|
19
19
|
- ๐ง **Memory Leak Detection**: Find missing cleanup in useEffect
|
|
20
20
|
- ๐ **Import Analysis**: Detect circular dependencies and barrel file issues
|
|
21
21
|
- ๐๏ธ **Unused Code Detection**: Find unused exports and dead imports
|
|
22
|
-
- ๐ **
|
|
22
|
+
- ๐ **Advanced Trend Analytics**: ML-powered trend analysis with predictions and health scores
|
|
23
23
|
- ๐ฌ **Chat Notifications**: Send analysis results to Slack, Discord, or custom webhooks
|
|
24
24
|
- ๐ **Dependency Graph Visualization**: Visual SVG/HTML of component and import relationships
|
|
25
25
|
- ๐ฆ **Bundle Size Impact**: Per-component bundle size estimates and optimization suggestions
|
|
@@ -27,6 +27,8 @@ A CLI tool that analyzes React projects and detects common code smells, providin
|
|
|
27
27
|
- ๐ง **Interactive Fix Mode**: Review and apply fixes one by one with diff preview
|
|
28
28
|
- ๐ฌ **GitHub PR Comments**: Auto-comment analysis results on pull requests
|
|
29
29
|
- ๐ **Performance Budget**: Set thresholds and enforce limits in CI/CD
|
|
30
|
+
- ๐ **PDF Report Generation**: Professional, printable reports with visual analytics
|
|
31
|
+
- ๐ฏ **ESLint Plugin Integration**: Run detectors directly as ESLint rules
|
|
30
32
|
- ๐ **Component Documentation**: Auto-generate docs from component analysis
|
|
31
33
|
- โ๏ธ **React 19 Server Components**: Detect Server/Client boundary issues
|
|
32
34
|
- ๐ฎ **Context API Analysis**: Detect context overuse, missing memoization, re-render issues
|
|
@@ -35,6 +37,11 @@ A CLI tool that analyzes React projects and detects common code smells, providin
|
|
|
35
37
|
- ๐๏ธ **State Management Analysis**: Redux/Zustand anti-patterns, selector issues
|
|
36
38
|
- ๐งช **Testing Gap Detection**: Identify complex components likely needing tests
|
|
37
39
|
- ๐ค **AI Refactoring Suggestions**: LLM-powered smart refactoring recommendations
|
|
40
|
+
- ๐ **Security Audit**: Comprehensive vulnerability scanning (XSS, injection, secrets, crypto issues)
|
|
41
|
+
- โก **Performance Profiler**: Component optimization analysis with memoization & render metrics
|
|
42
|
+
- ๐ฅ **Team Dashboard**: Centralized view of team metrics, workload & quality trends
|
|
43
|
+
- ๐ **API Integration**: Sync with GitHub, Slack, Jira, monitoring platforms & webhooks
|
|
44
|
+
- ๐ **Custom Analyzer**: Define and apply project-specific code quality rules
|
|
38
45
|
|
|
39
46
|
### Detected Code Smells
|
|
40
47
|
|
|
@@ -121,8 +128,317 @@ react-smell ./src -f markdown -o report.md
|
|
|
121
128
|
|
|
122
129
|
# HTML (beautiful visual report)
|
|
123
130
|
react-smell ./src -f html -o report.html
|
|
131
|
+
|
|
132
|
+
# PDF (professional formatted report with charts)
|
|
133
|
+
react-smell ./src -f pdf -o report.pdf
|
|
124
134
|
```
|
|
125
135
|
|
|
136
|
+
### ESLint Plugin Integration
|
|
137
|
+
|
|
138
|
+
Run code smell detection directly integrated with ESLint:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Install ESLint if not already installed
|
|
142
|
+
npm install -D eslint
|
|
143
|
+
|
|
144
|
+
# Add to .eslintrc.json
|
|
145
|
+
{
|
|
146
|
+
"plugins": ["react-code-smell-detector"],
|
|
147
|
+
"extends": ["plugin:react-code-smell-detector/recommended"]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
# Or use strict mode for more comprehensive checks
|
|
151
|
+
{
|
|
152
|
+
"plugins": ["react-code-smell-detector"],
|
|
153
|
+
"extends": ["plugin:react-code-smell-detector/strict"]
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Benefits:**
|
|
158
|
+
- Real-time feedback in your editor
|
|
159
|
+
- Integrates with existing ESLint workflow
|
|
160
|
+
- Runs on file save or pre-commit
|
|
161
|
+
- Works with git hooks and CI/CD pipelines
|
|
162
|
+
|
|
163
|
+
**Available ESLint Rules:**
|
|
164
|
+
- `no-excessive-use-effect`: Detect overuse of useEffect
|
|
165
|
+
- `no-prop-drilling`: Detect prop drilling patterns
|
|
166
|
+
- `no-large-components`: Warn on component size
|
|
167
|
+
- `no-unmemoized-calculations`: Flag unmemoized expensive operations
|
|
168
|
+
- `no-security-issues`: Detect security vulnerabilities
|
|
169
|
+
- `accessibility-checked`: Accessibility violations
|
|
170
|
+
- `no-memory-leaks`: Potential memory leaks
|
|
171
|
+
- `no-circular-dependencies`: Circular import detection
|
|
172
|
+
- `state-management-smell`: State management anti-patterns
|
|
173
|
+
- And 9 more rules for comprehensive coverage
|
|
174
|
+
|
|
175
|
+
### Advanced Trend Analytics
|
|
176
|
+
|
|
177
|
+
Track code quality trends over time with intelligent predictions and insights:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Enable trend analysis in baseline tracking
|
|
181
|
+
react-smell ./src --baseline --trend-analysis
|
|
182
|
+
|
|
183
|
+
# View detailed trend insights
|
|
184
|
+
react-smell ./src --baseline --trend-report
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Features:**
|
|
188
|
+
- **Trend Direction**: Automatic detection of improving, worsening, or stable trends
|
|
189
|
+
- **Growth Metrics**: Daily velocity, change rate, consistency scoring
|
|
190
|
+
- **Predictive Analytics**: Machine learning-based predictions for next 30 days
|
|
191
|
+
- **Health Score**: Overall codebase health indicator (0-100)
|
|
192
|
+
- **Zero Smell Timeline**: Estimated days to reach zero code smells
|
|
193
|
+
- **Seasonality Detection**: Identify patterns in code quality changes
|
|
194
|
+
- **Smart Recommendations**: AI-powered suggestions based on trend analysis
|
|
195
|
+
|
|
196
|
+
**Trend Analysis Output:**
|
|
197
|
+
```
|
|
198
|
+
๐ Trend Analysis
|
|
199
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
200
|
+
Current: 42 smells
|
|
201
|
+
Previous: 48 smells
|
|
202
|
+
Change: -12.5%
|
|
203
|
+
Trend: IMPROVING
|
|
204
|
+
|
|
205
|
+
โ
Health Score: 72/100 (good)
|
|
206
|
+
|
|
207
|
+
๐ Metrics
|
|
208
|
+
โข Daily Velocity: 0.75 smells/day (improving)
|
|
209
|
+
โข Consistency: 85%
|
|
210
|
+
โข Volatility: 2.1
|
|
211
|
+
|
|
212
|
+
๐ฎ Predictions
|
|
213
|
+
โข Next Month: ~35 smells
|
|
214
|
+
โข Trajectory: DOWNWARD
|
|
215
|
+
โข Confidence: 92%
|
|
216
|
+
โข Days to Zero Smells: 56
|
|
217
|
+
|
|
218
|
+
โจ Improvements
|
|
219
|
+
โข useEffect-overuse (3 fewer)
|
|
220
|
+
โข prop-drilling (2 fewer)
|
|
221
|
+
|
|
222
|
+
๐ก Recommendations
|
|
223
|
+
๐ข Path to Code Smell-Free Codebase
|
|
224
|
+
At the current improvement rate, your codebase could be
|
|
225
|
+
smell-free in approximately 56 days. Focus on maintaining
|
|
226
|
+
this momentum.
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Configuration:**
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"baselineEnabled": true,
|
|
233
|
+
"trendAnalysisEnabled": true,
|
|
234
|
+
"trendReportFrequency": "weekly",
|
|
235
|
+
"predictiveDaysLookahead": 30
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### PDF Report Generation
|
|
240
|
+
|
|
241
|
+
Generate professional, printable PDF reports with visual analytics:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Generate PDF report
|
|
245
|
+
react-smell ./src -f pdf -o smell-report.pdf
|
|
246
|
+
|
|
247
|
+
# Include code snippets in PDF
|
|
248
|
+
react-smell ./src -f pdf -o report.pdf --snippets
|
|
249
|
+
|
|
250
|
+
# Generate PDF with trend analysis
|
|
251
|
+
react-smell ./src -f pdf -o report.pdf --baseline --trend-analysis
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**PDF Report Contents:**
|
|
255
|
+
- Executive Summary with key metrics
|
|
256
|
+
- Technical Debt Grade with visual indicators
|
|
257
|
+
- Smell breakdown by type and severity
|
|
258
|
+
- Top affected files with risk levels
|
|
259
|
+
- Detailed smell analysis with code snippets
|
|
260
|
+
- Actionable recommendations prioritized by impact
|
|
261
|
+
- Trend analysis and predictions
|
|
262
|
+
- Estimated refactoring timeline
|
|
263
|
+
|
|
264
|
+
**Visual Elements:**
|
|
265
|
+
- Color-coded severity levels (error/warning/info)
|
|
266
|
+
- Grade badges with color gradients
|
|
267
|
+
- Data visualizations and charts
|
|
268
|
+
- Summary metrics in card layout
|
|
269
|
+
- Code snippets with syntax highlighting
|
|
270
|
+
- Professional typography and layout
|
|
271
|
+
|
|
272
|
+
**Use Cases:**
|
|
273
|
+
- Share reports with stakeholders
|
|
274
|
+
- Archive analysis history
|
|
275
|
+
- Print for code review meetings
|
|
276
|
+
- Executive dashboards
|
|
277
|
+
- Compliance documentation
|
|
278
|
+
|
|
279
|
+
### Security Audit
|
|
280
|
+
|
|
281
|
+
Comprehensive security vulnerability scanning and compliance analysis:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# Run security audit
|
|
285
|
+
react-smell ./src --security-audit
|
|
286
|
+
|
|
287
|
+
# Include secret detection
|
|
288
|
+
react-smell ./src --security-audit --check-secrets
|
|
289
|
+
|
|
290
|
+
# Generate security report
|
|
291
|
+
react-smell ./src --security-audit -f json -o security-report.json
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Detects:**
|
|
295
|
+
- **XSS Vulnerabilities**: dangerouslySetInnerHTML, innerHTML assignment, eval() usage
|
|
296
|
+
- **Injection Attacks**: SQL injection, command injection, regex injection patterns
|
|
297
|
+
- **Secrets Exposure**: API keys, passwords, tokens, private keys
|
|
298
|
+
- **Cryptography Issues**: Deprecated cipher functions, weak hashing (MD5, SHA1), weak random generation
|
|
299
|
+
- **CVSS Scoring**: Risk assessment with industry-standard vulnerability scoring
|
|
300
|
+
|
|
301
|
+
**Output:** Compliance score, risk level, critical/high/medium/low categorization, remediation suggestions
|
|
302
|
+
|
|
303
|
+
### Performance Profiler
|
|
304
|
+
|
|
305
|
+
Analyze and optimize component performance characteristics:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Profile performance metrics
|
|
309
|
+
react-smell ./src --performance
|
|
310
|
+
|
|
311
|
+
# Get detailed performance analysis
|
|
312
|
+
react-smell ./src --performance --detailed
|
|
313
|
+
|
|
314
|
+
# Export performance metrics
|
|
315
|
+
react-smell ./src --performance -f json -o perf-metrics.json
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Analyzes:**
|
|
319
|
+
- **Render Time**: Estimated component rendering duration
|
|
320
|
+
- **Memory Usage**: Approximate memory footprint per component
|
|
321
|
+
- **Memoization Score**: Identifies missing useMemo/useCallback opportunities (0-100)
|
|
322
|
+
- **Render Efficiency**: Optimization potential rating
|
|
323
|
+
- **Bottleneck Detection**: Identifies slow, memory-intensive, or re-render-heavy components
|
|
324
|
+
- **Hook Usage**: State and effect hook analysis for consolidation opportunities
|
|
325
|
+
|
|
326
|
+
### Team Dashboard
|
|
327
|
+
|
|
328
|
+
Centralized metrics view for team collaboration and quality tracking:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
# Generate team dashboard
|
|
332
|
+
react-smell dashboard
|
|
333
|
+
|
|
334
|
+
# Include team members
|
|
335
|
+
react-smell dashboard --team-members team.json
|
|
336
|
+
|
|
337
|
+
# View in CI/CD pipeline
|
|
338
|
+
react-smell dashboard -f json | post-to-dashboard-api
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Features:**
|
|
342
|
+
- **Team Metrics**: Member count, component ownership, average code quality
|
|
343
|
+
- **Health Status**: Excellent/Good/Fair/Poor/Critical team health indicator
|
|
344
|
+
- **Common Issues**: Top code smells affecting the team with frequency counts
|
|
345
|
+
- **Activity Log**: Recent analysis events with timestamps
|
|
346
|
+
- **Alerts**: Critical issues, component overload warnings, team workload indicators
|
|
347
|
+
- **Ownership Tracking**: Component assignment to team members
|
|
348
|
+
|
|
349
|
+
### API Integration
|
|
350
|
+
|
|
351
|
+
Sync analysis results with external services, issue trackers, and monitoring platforms:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Send to external API
|
|
355
|
+
react-smell ./src --send-to-api https://api.example.com --api-key sk-xxx
|
|
356
|
+
|
|
357
|
+
# Post issues to GitHub/GitLab
|
|
358
|
+
react-smell ./src --post-issues --github --token $GITHUB_TOKEN
|
|
359
|
+
|
|
360
|
+
# Send Slack notifications
|
|
361
|
+
react-smell ./src --webhook https://hooks.slack.com/services/xxx
|
|
362
|
+
|
|
363
|
+
# Check SLA compliance
|
|
364
|
+
react-smell ./src --check-sla ./sla-config.json
|
|
365
|
+
|
|
366
|
+
# Comment on pull requests
|
|
367
|
+
react-smell ./src --comment-pr --pr-number 123 --pr-token $TOKEN
|
|
368
|
+
|
|
369
|
+
# Sync to monitoring platform
|
|
370
|
+
react-smell ./src --sync-metrics https://metrics.service.com
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Integrations:**
|
|
374
|
+
- GitHub Issues, GitHub Pull Request Comments, GitHub Actions
|
|
375
|
+
- GitLab Issues, Merge Request comments
|
|
376
|
+
- Jira issue creation and linking
|
|
377
|
+
- Slack notifications and dashboards
|
|
378
|
+
- Discord webhooks
|
|
379
|
+
- Datadog, New Relic, and other APM platforms
|
|
380
|
+
- Custom REST API endpoints
|
|
381
|
+
- SLA monitoring and compliance checking
|
|
382
|
+
|
|
383
|
+
### Custom Analyzer
|
|
384
|
+
|
|
385
|
+
Define and apply project-specific code quality rules:
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Create custom rules
|
|
389
|
+
react-smell init --custom-rules
|
|
390
|
+
|
|
391
|
+
# Apply custom rules
|
|
392
|
+
react-smell ./src --custom-rules ./custom-rules.json
|
|
393
|
+
|
|
394
|
+
# Validate rules before applying
|
|
395
|
+
react-smell ./src --validate-rules ./custom-rules.json
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Example Custom Rules:**
|
|
399
|
+
|
|
400
|
+
```json
|
|
401
|
+
{
|
|
402
|
+
"customRules": [
|
|
403
|
+
{
|
|
404
|
+
"id": "no-magic-numbers",
|
|
405
|
+
"name": "No Magic Numbers",
|
|
406
|
+
"pattern": "[0-9]{3,}",
|
|
407
|
+
"severity": "warning",
|
|
408
|
+
"message": "Magic number found",
|
|
409
|
+
"suggestion": "Extract to named constant",
|
|
410
|
+
"enabled": true
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"id": "naming-convention",
|
|
414
|
+
"name": "Component Naming",
|
|
415
|
+
"pattern": "^[a-z].*\\.tsx$",
|
|
416
|
+
"severity": "warning",
|
|
417
|
+
"message": "Component name must start with uppercase",
|
|
418
|
+
"suggestion": "Use PascalCase",
|
|
419
|
+
"enabled": true
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"id": "no-console-in-prod",
|
|
423
|
+
"name": "No Console in Production",
|
|
424
|
+
"pattern": "console\\.(log|warn|error)",
|
|
425
|
+
"severity": "info",
|
|
426
|
+
"message": "Console statement detected",
|
|
427
|
+
"suggestion": "Remove or use logger",
|
|
428
|
+
"enabled": false
|
|
429
|
+
}
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Rule Features:**
|
|
435
|
+
- String and regex pattern matching
|
|
436
|
+
- File/component/function/expression scope filtering
|
|
437
|
+
- Include/exclude patterns for file filtering
|
|
438
|
+
- Enable/disable rules individually
|
|
439
|
+
- Custom severity levels
|
|
440
|
+
- Multi-line pattern matching
|
|
441
|
+
|
|
126
442
|
### Configuration
|
|
127
443
|
|
|
128
444
|
Create a `.smellrc.json` file:
|
|
@@ -142,11 +458,28 @@ Or create manually:
|
|
|
142
458
|
}
|
|
143
459
|
```
|
|
144
460
|
|
|
461
|
+
Create a `.smellrc.json` file:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
react-smell init
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Or create manually:
|
|
468
|
+
|
|
469
|
+
```json
|
|
470
|
+
{
|
|
471
|
+
"maxUseEffectsPerComponent": 3,
|
|
472
|
+
"maxPropDrillingDepth": 3,
|
|
473
|
+
"maxComponentLines": 300,
|
|
474
|
+
"maxPropsCount": 7
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
145
478
|
### CLI Options
|
|
146
479
|
|
|
147
480
|
| Option | Description | Default |
|
|
148
481
|
|--------|-------------|---------|
|
|
149
|
-
| `-f, --format <format>` | Output format: console, json, markdown, html | `console` |
|
|
482
|
+
| `-f, --format <format>` | Output format: console, json, markdown, html, pdf | `console` |
|
|
150
483
|
| `-s, --snippets` | Show code snippets in output | `false` |
|
|
151
484
|
| `-c, --config <file>` | Path to config file | `.smellrc.json` |
|
|
152
485
|
| `--ci` | CI mode: exit with code 1 if any issues | `false` |
|
|
@@ -161,6 +494,8 @@ Or create manually:
|
|
|
161
494
|
| `--exclude <patterns>` | Glob patterns to exclude | `node_modules,dist` |
|
|
162
495
|
| `-o, --output <file>` | Write output to file | - |
|
|
163
496
|
| `--baseline` | Enable baseline tracking and trend analysis | `false` |
|
|
497
|
+
| `--trend-analysis` | Show detailed trend analysis and predictions | `false` |
|
|
498
|
+
| `--trend-report` | Generate comprehensive trend report | `false` |
|
|
164
499
|
| `--slack <url>` | Slack webhook URL for notifications | - |
|
|
165
500
|
| `--discord <url>` | Discord webhook URL for notifications | - |
|
|
166
501
|
| `--webhook <url>` | Generic webhook URL for notifications | - |
|
|
@@ -618,6 +953,11 @@ react-smell ./src
|
|
|
618
953
|
import {
|
|
619
954
|
analyzeProject,
|
|
620
955
|
reportResults,
|
|
956
|
+
// PDF Reporting
|
|
957
|
+
generatePDFReport,
|
|
958
|
+
// Trend Analytics
|
|
959
|
+
analyzeTrends,
|
|
960
|
+
formatTrendAnalysis,
|
|
621
961
|
// Interactive fixing
|
|
622
962
|
runInteractiveFix,
|
|
623
963
|
previewFixes,
|
|
@@ -631,6 +971,9 @@ import {
|
|
|
631
971
|
// Documentation
|
|
632
972
|
generateComponentDocs,
|
|
633
973
|
writeComponentDocs,
|
|
974
|
+
// Baseline & Trends
|
|
975
|
+
recordBaseline,
|
|
976
|
+
initializeBaseline,
|
|
634
977
|
} from 'react-code-smell-detector';
|
|
635
978
|
|
|
636
979
|
const result = await analyzeProject({
|
|
@@ -646,6 +989,28 @@ const result = await analyzeProject({
|
|
|
646
989
|
console.log(`Grade: ${result.debtScore.grade}`);
|
|
647
990
|
console.log(`Total issues: ${result.summary.totalSmells}`);
|
|
648
991
|
|
|
992
|
+
// Generate PDF report
|
|
993
|
+
await generatePDFReport(result, {
|
|
994
|
+
outputPath: './report.pdf',
|
|
995
|
+
rootDir: './src',
|
|
996
|
+
includeCharts: true,
|
|
997
|
+
includeCodeSnippets: true,
|
|
998
|
+
title: 'Code Quality Report',
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
// Record baseline for trend tracking
|
|
1002
|
+
initializeBaseline('./');
|
|
1003
|
+
const baselineRecord = recordBaseline('./', result.smells);
|
|
1004
|
+
|
|
1005
|
+
// Analyze trends from baseline history
|
|
1006
|
+
// (requires multiple baseline recordings over time)
|
|
1007
|
+
import { BaselineData } from 'react-code-smell-detector';
|
|
1008
|
+
const baselineData: BaselineData = JSON.parse(
|
|
1009
|
+
fs.readFileSync('.smellrc-baseline.json', 'utf-8')
|
|
1010
|
+
);
|
|
1011
|
+
const trendAnalysis = analyzeTrends(baselineData);
|
|
1012
|
+
console.log(formatTrendAnalysis(trendAnalysis));
|
|
1013
|
+
|
|
649
1014
|
// Check against performance budget
|
|
650
1015
|
const budget = await loadBudget();
|
|
651
1016
|
const budgetResult = checkBudget(result, budget);
|
|
@@ -662,7 +1027,7 @@ const docsPath = await writeComponentDocs(result, './src', {
|
|
|
662
1027
|
// Generate PR comment
|
|
663
1028
|
const prComment = generatePRComment(result, './src');
|
|
664
1029
|
|
|
665
|
-
// Or use the reporter
|
|
1030
|
+
// Or use the reporter for any format
|
|
666
1031
|
const report = reportResults(result, {
|
|
667
1032
|
format: 'markdown',
|
|
668
1033
|
showCodeSnippets: true,
|
|
@@ -670,6 +1035,26 @@ const report = reportResults(result, {
|
|
|
670
1035
|
});
|
|
671
1036
|
```
|
|
672
1037
|
|
|
1038
|
+
**Trend Analytics API:**
|
|
1039
|
+
```typescript
|
|
1040
|
+
import { TrendAnalysis, TrendPrediction } from 'react-code-smell-detector';
|
|
1041
|
+
|
|
1042
|
+
// Access trend data
|
|
1043
|
+
const currentHealth = trendAnalysis.healthScore; // HealthScore
|
|
1044
|
+
const predictions = trendAnalysis.predictions; // TrendPrediction
|
|
1045
|
+
const metrics = trendAnalysis.metrics; // TrendMetrics
|
|
1046
|
+
const recommendations = trendAnalysis.recommendations; // TrendRecommendation[]
|
|
1047
|
+
|
|
1048
|
+
// Timeline to zero smells
|
|
1049
|
+
if (predictions.daysToZeroSmells) {
|
|
1050
|
+
console.log(`Projected zero smells in ${predictions.daysToZeroSmells} days`);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// Access velocity and consistency metrics
|
|
1054
|
+
console.log(`Daily Velocity: ${metrics.velocityPerDay} smells/day`);
|
|
1055
|
+
console.log(`Consistency: ${metrics.consistency}%`);
|
|
1056
|
+
```
|
|
1057
|
+
|
|
673
1058
|
## CI/CD Integration
|
|
674
1059
|
|
|
675
1060
|
The tool provides flexible exit codes and notification capabilities for CI/CD pipelines:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-code-smell-detector",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Detect code smells in React projects - useEffect overuse, prop drilling, large components, security issues, accessibility, memory leaks, React 19 Server Components, and more",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|