react-code-smell-detector 1.5.2 โ 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 +168 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,11 @@ A CLI tool that analyzes React projects and detects common code smells, providin
|
|
|
37
37
|
- ๐๏ธ **State Management Analysis**: Redux/Zustand anti-patterns, selector issues
|
|
38
38
|
- ๐งช **Testing Gap Detection**: Identify complex components likely needing tests
|
|
39
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
|
|
40
45
|
|
|
41
46
|
### Detected Code Smells
|
|
42
47
|
|
|
@@ -271,6 +276,169 @@ react-smell ./src -f pdf -o report.pdf --baseline --trend-analysis
|
|
|
271
276
|
- Executive dashboards
|
|
272
277
|
- Compliance documentation
|
|
273
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
|
+
|
|
274
442
|
### Configuration
|
|
275
443
|
|
|
276
444
|
Create a `.smellrc.json` file:
|
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": {
|