Benign repos Download

dead-code.rule.ts

imports node:fsCalls a matcher in a conditional expression
SHA-256e7cb7f7699b097871a18d1bf914b0119a4e5729ac9dbaa2c91b2a7b0572e3d73
MaleculeH(Db)Md(In)

Evidence

imports node:fs lines 1–17
1import * as fs from 'node:fs';
2import { SyntaxKind, type Project, type SourceFile } from 'ts-morph';
3
4import { BaseRule } from './base-rule.js';
5import { getConfig } from '../config.js';
6import type { Violation, FixResult } from '../types.js';
7import { getRelativePath } from '../utils/paths.js';
8
9/**
10 * Dead Code Rule
11 *
12 * Finds and optionally removes unused methods, properties, and classes.
13 * Uses reference tracing to detect code that isn't used anywhere in the codebase.
14 *
15 * Detects:
16 * - Unused public methods (no external references)
17 * - Unused public …
English function-word token "with" lines 19–25
19:19… (no public members)
20 *
21 * Supports auto-fixing with --fix --write
22 */
23export class DeadCodeRule extends BaseRule {
24 readonly id = 'dead-code';
25 rea …
English function-word token "for" lines 40–49
40:56… ion[] {
41 const violations: Violation[] = [];
42
43 for (const file of files) {
44 const fileViolations = this.analyzeFile(project, file);
45 violations.push(...fileViolations);
46 }
47
48 return violations;
49 } …
Calls a matcher in a conditional expression lines 167–178
167:27… ct.getSourceFiles()) {
168 if (file === sourceFile) continue;
169 if (pattern.test(file.getFullText())) {
170 return true;
171 }
⋯7 lines

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.