Sistema de Auditoria de Código Morto Cirúrgico

De Wikiprompt, a enciclopédia livre de prompts

Ersin KOÇ
Contribuído porErsin KOÇFonte

8 de mar. de 2026

Sistema de Auditoria de Código Morto Cirúrgico Um prompt de sistema estruturado para IA realizar uma auditoria abrangente de código morto, incluindo fases de descoberta, verificação, triagem e relatório.

Conteúdo do PromptSalvar

🌐
### 1. Findings Table | # | File | Line(s) | Symbol | Category | Risk | Confidence | Action | |---|------|---------|--------|----------|------|------------|--------| | 1 | `src/utils/legacy/dateFormatter.js` | 1-87 | `formatLegacyDate` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 2 | `src/utils/legacy/dateFormatter.js` | 89-120 | `parseLegacyDate` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 3 | `src/utils/legacy/dateFormatter.js` | 122-145 | `isLeapYear` | UNREACHABLE_DECL | 🔴 HIGH | 90% | DELETE | | 4 | `src/services/analytics/tracker.js` | 45-78 | `trackPageView` | UNREACHABLE_DECL | 🟡 MEDIUM | 70% | MANUAL_VERIFY | | 5 | `src/services/analytics/tracker.js` | 80-102 | `trackEvent` | UNREACHABLE_DECL | 🟡 MEDIUM | 70% | MANUAL_VERIFY | | 6 | `src/services/analytics/tracker.js` | 104-130 | `trackConversion` | UNREACHABLE_DECL | 🟡 MEDIUM | 70% | MANUAL_VERIFY | | 7 | `src/config/featureFlags.js` | 12 | `ENABLE_NEW_CHECKOUT` | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 8 | `src/config/featureFlags.js` | 15 | `USE_REDIS_CACHE` | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 9 | `src/config/featureFlags.js` | 18 | `SHOW_BETA_BANNER` | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 10 | `src/components/Checkout.jsx` | 34-56 | `if (ENABLE_NEW_CHECKOUT)` | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 11 | `src/components/Checkout.jsx` | 58-72 | `else` branch (legacy checkout) | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 12 | `src/cache/redisClient.js` | 1-15 | `import redis` | PHANTOM_DEP | 🔴 HIGH | 95% | DELETE | | 13 | `src/cache/redisClient.js` | 17-40 | `RedisClient` class | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 14 | `src/cache/redisClient.js` | 42-60 | `getCache` / `setCache` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 15 | `src/components/Header.jsx` | 8 | `import { SHOW_BETA_BANNER }` | PHANTOM_DEP | 🔴 HIGH | 98% | DELETE | | 16 | `src/components/Header.jsx` | 22-30 | `if (SHOW_BETA_BANNER)` block | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 17 | `src/utils/helpers.js` | 40-55 | `debounce` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 18 | `src/utils/helpers.js` | 57-70 | `throttle` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 19 | `src/utils/helpers.js` | 72-85 | `memoize` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 20 | `src/models/User.js` | 1-120 | `User` model (entire file) | UNREACHABLE_DECL | 🟢 LOW | 40% | MANUAL_VERIFY | | 21 | `src/models/Product.js` | 1-95 | `Product` model (entire file) | UNREACHABLE_DECL | 🟢 LOW | 40% | MANUAL_VERIFY | | 22 | `src/models/Order.js` | 1-110 | `Order` model (entire file) | UNREACHABLE_DECL | 🟢 LOW | 40% | MANUAL_VERIFY | | 23 | `src/constants/statusCodes.js` | 1-30 | `HTTP_STATUS` object | UNREACHABLE_DECL | 🟡 MEDIUM | 75% | MANUAL_VERIFY | | 24 | `src/constants/errorMessages.js` | 1-45 | `ERROR_MESSAGES` object | UNREACHABLE_DECL | 🟡 MEDIUM | 75% | MANUAL_VERIFY | | 25 | `src/middleware/auth.js` | 15-40 | `authenticate` | UNREACHABLE_DECL | 🟡 MEDIUM | 65% | MANUAL_VERIFY | | 26 | `src/middleware/logger.js` | 10-35 | `requestLogger` | UNREACHABLE_DECL | 🟡 MEDIUM | 65% | MANUAL_VERIFY | | 27 | `src/middleware/errorHandler.js` | 12-50 | `errorHandler` | UNREACHABLE_DECL | 🟡 MEDIUM | 65% | MANUAL_VERIFY | | 28 | `src/utils/validators.js` | 20-45 | `validateEmail` | UNREACHABLE_DECL | 🟡 MEDIUM | 55% | MANUAL_VERIFY | | 29 | `src/utils/validators.js` | 47-60 | `validatePhone` | UNREACHABLE_DECL | 🟡 MEDIUM | 55% | MANUAL_VERIFY | | 30 | `src/utils/validators.js` | 62-75 | `validateZipCode` | UNREACHABLE_DECL | 🟡 MEDIUM | 55% | MANUAL_VERIFY | | 31 | `src/utils/validators.js` | 77-90 | `validateCreditCard` | UNREACHABLE_DECL | 🟡 MEDIUM | 55% | MANUAL_VERIFY | | 32 | `src/services/email/sender.js` | 1-80 | `EmailSender` class | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 33 | `src/services/email/templates.js` | 1-60 | `renderWelcomeEmail` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 34 | `src/services/email/templates.js` | 62-90 | `renderResetPasswordEmail` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 35 | `src/services/email/templates.js` | 92-120 | `renderOrderConfirmationEmail` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 36 | `src/utils/legacy/` (directory) | - | Entire directory | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 37 | `src/cache/` (directory) | - | Entire directory | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 38 | `src/config/featureFlags.js` | 1-30 | Entire file | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 39 | `src/utils/legacy/dateFormatter.js` | 1-145 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 40 | `src/cache/redisClient.js` | 1-60 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 41 | `src/components/Checkout.jsx` | 58-72 | Legacy checkout branch | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 42 | `src/components/Header.jsx` | 22-30 | Beta banner block | DEAD_FLOW | 🔴 HIGH | 98% | DELETE | | 43 | `src/utils/helpers.js` | 40-85 | `debounce` / `throttle` / `memoize` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 44 | `src/models/` (directory) | - | `User` / `Product` / `Order` | UNREACHABLE_DECL | 🟢 LOW | 40% | MANUAL_VERIFY | | 45 | `src/constants/` (directory) | - | `statusCodes` / `errorMessages` | UNREACHABLE_DECL | 🟡 MEDIUM | 75% | MANUAL_VERIFY | | 46 | `src/middleware/` (directory) | - | `auth` / `logger` / `errorHandler` | UNREACHABLE_DECL | 🟡 MEDIUM | 65% | MANUAL_VERIFY | | 47 | `src/utils/validators.js` | 20-90 | All validator functions | UNREACHABLE_DECL | 🟡 MEDIUM | 55% | MANUAL_VERIFY | | 48 | `src/services/email/` (directory) | - | `sender` / `templates` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 49 | `src/utils/legacy/dateFormatter.js` | 1-145 | `formatLegacyDate` / `parseLegacyDate` / `isLeapYear` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 50 | `src/cache/redisClient.js` | 1-60 | `RedisClient` / `getCache` / `setCache` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | ### 2. Cleanup Roadmap **Batch 1 - HIGH Risk (Immediate Deletion)** - **Files to touch:** `src/utils/legacy/dateFormatter.js`, `src/cache/redisClient.js`, `src/config/featureFlags.js`, `src/components/Checkout.jsx`, `src/components/Header.jsx` - **Estimated LOC removed:** ~450 - **Bundle size impact:** ~12 KB (minified) / ~4 KB (gzipped) - **Refactoring order:** 1. Delete `src/config/featureFlags.js` and remove all imports 2. Remove dead branches in `Checkout.jsx` and `Header.jsx` 3. Delete `src/cache/` directory and its imports 4. Delete `src/utils/legacy/` directory 5. Run full test suite to verify no regressions **Batch 2 - MEDIUM Risk (Verify Before Deleting)** - **Files to touch:** `src/utils/helpers.js`, `src/constants/`, `src/middleware/`, `src/utils/validators.js`, `src/services/email/`, `src/services/analytics/tracker.js` - **Estimated LOC removed:** ~600 - **Bundle size impact:** ~15 KB (minified) / ~5 KB (gzipped) - **Refactoring order:** 1. Grep for dynamic imports, string-based references, or config-driven usage 2. Check for test files referencing these modules 3. Check for any external consumers (if this is a library) 4. Remove confirmed dead code, archive uncertain ones 5. Run tests and linting after each removal **Batch 3 - LOW Risk (Human Review Required)** - **Files to touch:** `src/models/` - **Estimated LOC removed:** ~325 - **Bundle size impact:** ~8 KB (minified) / ~3 KB (gzipped) - **Refactoring order:** 1. Check ORM configuration for model registration 2. Check for serialization/deserialization references 3. Check for any dynamic model instantiation 4. If confirmed unused, delete or move to archive 5. Update any documentation referencing these models ### 3. Executive Summary | Metric | Count | |--------|-------| | Total findings | 50 | | High-confidence deletes | 15 | | Estimated LOC removed | ~1,375 | | Estimated dead imports | 8 | | Files safe to delete entirely | 4 | | Estimated build time improvement | ~15% | **Overall Codebase Health Assessment:** The codebase shows signs of moderate technical debt accumulation, primarily from legacy code that survived multiple refactoring cycles. The presence of hardcoded feature flags, an entire legacy date utility module, and an unused Redis cache layer indicates that past architectural decisions were never fully cleaned up. The dead code is concentrated in well-defined areas, making cleanup relatively straightforward. However, the medium-risk findings in middleware, validators, and email services suggest that some code may be used indirectly through framework hooks or configuration, requiring careful verification before removal. **Top 3 Highest-Impact Actions:** 1. **Delete the legacy date formatter and Redis cache modules** - These are self-contained, high-confidence dead code that immediately reduces bundle size and removes ~250 LOC with zero risk. 2. **Remove hardcoded feature flags and their dead branches** - This simplifies the checkout and header components, eliminates ~200 LOC of conditional logic, and makes the codebase more readable. 3. **Audit the middleware and validator modules** - These are likely used by the framework (Express middleware chain) or through dynamic imports. A focused grep for string references and framework registration will clarify their status and potentially unlock another ~300 LOC of cleanup.

Entre para ver o prompt completo

Continuar com:

Ao entrar, você concorda com nossos Termos de uso e Política de privacidade

Uso

Este prompt foi projetado para uso com coding. Copie o conteúdo acima e cole na sua ferramenta de IA preferida.

Para melhores resultados, personalize os marcadores (indicados por colchetes ou maiúsculas) com seus requisitos específicos.

Referências

Categorias:coding| prompts.chat| dead-code| code-audit

Discussão

0 comentários