Skip to content

Commit 2674b20

Browse files
ozgesolidkeyclaude
andcommitted
Clean up dead code and enable noUnusedLocals
Remove unused variables and dead code across the codebase: - Remove unused imports (LiveConnectionInfo, ContextPattern, SshProfile) - Remove dead functions (parseTimestamp, extractTimestampString in index.ts) - Remove unused locals (componentMentions, visibleCols, endTime, etc.) - Clean up write-only SSE state tracking in MCP server - Enable noUnusedLocals in tsconfig to prevent future dead code All 271 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3e1a638 commit 2674b20

9 files changed

Lines changed: 7 additions & 80 deletions

File tree

src/main/baselineStore.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ export function buildFingerprint(
147147

148148
// Single pass through the file
149149
let startTime: Date | null = null;
150-
let endTime: Date | null = null;
151150
const minuteBuckets = new Map<number, number>(); // minute offset -> count
152151

153152
const batchSize = 10000;
@@ -159,7 +158,6 @@ export function buildFingerprint(
159158
const ts = parseTimestamp(line.text);
160159
if (ts) {
161160
if (!startTime) startTime = ts;
162-
endTime = ts;
163161
if (startTime) {
164162
const minuteOffset = Math.floor((ts.getTime() - startTime.getTime()) / 60000);
165163
if (minuteOffset >= 0 && minuteOffset < 1440) {

src/main/index.ts

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (process.platform !== 'linux') {
1515
console.warn('node-pty not available on Linux — using child_process fallback for terminal');
1616
}
1717
import { FileHandler, filterLineToVisibleColumns, ColumnConfig } from './fileHandler';
18-
import { IPC, SearchOptions, Bookmark, Highlight, HighlightGroup, SearchConfig, SearchConfigSession, ActivityEntry, LocalFileData, LiveConnectionInfo, ContextDefinition, ContextPattern, ContextMatchGroup, Annotation } from '../shared/types';
18+
import { IPC, SearchOptions, Bookmark, Highlight, HighlightGroup, SearchConfig, SearchConfigSession, ActivityEntry, LocalFileData, ContextDefinition, ContextMatchGroup, Annotation } from '../shared/types';
1919
import * as Diff from 'diff';
2020
import { analyzerRegistry, AnalyzerOptions, AnalysisResult } from './analyzers';
2121
import { loadDatadogConfig, saveDatadogConfig, clearDatadogConfig, fetchDatadogLogs, DatadogConfig, DatadogFetchParams } from './datadogClient';
@@ -1348,7 +1348,6 @@ app.whenReady().then(() => {
13481348
// Scan the range
13491349
const levelCounts: Record<string, number> = {};
13501350
const crashes: { lineNumber: number; keyword: string; text: string }[] = [];
1351-
const componentMentions: Record<string, { lineCount: number; errorCount: number }> = {};
13521351
const CRASH_KEYWORDS = ['fatal', 'panic', 'crash', 'exception', 'segfault', 'abort', 'oom', 'killed', 'core dump'];
13531352
const timeGaps: { lineNumber: number; gapSeconds: number; prevTimestamp: string; currTimestamp: string }[] = [];
13541353
let prevTimestamp: Date | null = null;
@@ -2593,7 +2592,6 @@ ipcMain.handle(IPC.SEARCH, async (_, options: SearchOptions) => {
25932592

25942593
// Check for hidden column matches (matches in columns that are filtered out)
25952594
if (options.columnConfig) {
2596-
const visibleCols = options.columnConfig.columns.filter(c => c.visible).map(c => c.index);
25972595
const hiddenCols = options.columnConfig.columns.filter(c => !c.visible).map(c => c.index);
25982596
if (hiddenCols.length > 0) {
25992597
// Do a full-text search (without column config) to find matches in hidden columns
@@ -4521,70 +4519,11 @@ interface TimeGap {
45214519
linePreview: string;
45224520
}
45234521

4524-
// Timestamp patterns for parsing
4525-
const TIME_GAP_PATTERNS = [
4526-
// ISO format: 2024-01-25T10:00:01 or 2024-01-25 10:00:01
4527-
/(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})/,
4528-
// European format: DD.MM.YYYY HH:mm:ss (e.g., 02.01.2026 18:16:01.061)
4529-
/(\d{2})\.(\d{2})\.(\d{4})\s+(\d{2}):(\d{2}):(\d{2})/,
4530-
// Syslog format: Jan 25 10:00:01 (assumes current year)
4531-
/([A-Z][a-z]{2})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})/,
4532-
];
4533-
45344522
const MONTH_MAP: Record<string, number> = {
45354523
'Jan': 0, 'Feb': 1, 'Mar': 2, 'Apr': 3, 'May': 4, 'Jun': 5,
45364524
'Jul': 6, 'Aug': 7, 'Sep': 8, 'Oct': 9, 'Nov': 10, 'Dec': 11
45374525
};
45384526

4539-
function parseTimestamp(text: string): Date | null {
4540-
const sample = text.length > 100 ? text.substring(0, 100) : text;
4541-
4542-
// Try ISO format first
4543-
const isoMatch = sample.match(TIME_GAP_PATTERNS[0]);
4544-
if (isoMatch) {
4545-
const [, year, month, day, hour, min, sec] = isoMatch;
4546-
return new Date(
4547-
parseInt(year), parseInt(month) - 1, parseInt(day),
4548-
parseInt(hour), parseInt(min), parseInt(sec)
4549-
);
4550-
}
4551-
4552-
// Try European format: DD.MM.YYYY HH:mm:ss
4553-
const euroMatch = sample.match(TIME_GAP_PATTERNS[1]);
4554-
if (euroMatch) {
4555-
const [, day, month, year, hour, min, sec] = euroMatch;
4556-
return new Date(
4557-
parseInt(year), parseInt(month) - 1, parseInt(day),
4558-
parseInt(hour), parseInt(min), parseInt(sec)
4559-
);
4560-
}
4561-
4562-
// Try syslog format
4563-
const syslogMatch = sample.match(TIME_GAP_PATTERNS[2]);
4564-
if (syslogMatch) {
4565-
const [, monthStr, day, hour, min, sec] = syslogMatch;
4566-
const month = MONTH_MAP[monthStr];
4567-
if (month !== undefined) {
4568-
const now = new Date();
4569-
return new Date(
4570-
now.getFullYear(), month, parseInt(day),
4571-
parseInt(hour), parseInt(min), parseInt(sec)
4572-
);
4573-
}
4574-
}
4575-
4576-
return null;
4577-
}
4578-
4579-
function extractTimestampString(text: string): string | null {
4580-
const sample = text.length > 100 ? text.substring(0, 100) : text;
4581-
for (const pattern of TIME_GAP_PATTERNS) {
4582-
const match = sample.match(pattern);
4583-
if (match) return match[0];
4584-
}
4585-
return null;
4586-
}
4587-
45884527
interface TimeGapOptions {
45894528
thresholdSeconds: number;
45904529
startLine?: number;

src/main/sshHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from 'path';
44
import * as os from 'os';
55
import { Client, SFTPWrapper } from 'ssh2';
66
import type { FileEntry } from 'ssh2';
7-
import { SshProfile, SshStatus } from '../shared/types';
7+
import { SshStatus } from '../shared/types';
88
import { wallClockPrefix } from './serialHandler';
99

1010
export interface SshHostEntry {

src/mcp-server/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ interface ChatMessage {
9191

9292
let sseBuffer: ChatMessage[] = [];
9393
let sseWaiters: Array<(msg: ChatMessage) => void> = [];
94-
let sseConnected = false;
95-
let sseReconnectTimer: ReturnType<typeof setTimeout> | null = null;
9694

9795
let keepAliveTimer: ReturnType<typeof setInterval> | null = null;
9896

@@ -108,14 +106,13 @@ function connectSSE(): void {
108106
const port = getApiPort();
109107
if (!port) {
110108
// Retry after a delay
111-
sseReconnectTimer = setTimeout(connectSSE, 5000);
109+
setTimeout(connectSSE, 5000);
112110
return;
113111
}
114112

115113
startKeepAlive(port);
116114

117115
const req = http.get(`http://127.0.0.1:${port}/api/events`, (res) => {
118-
sseConnected = true;
119116
let buffer = '';
120117

121118
res.on('data', (chunk: Buffer) => {
@@ -150,14 +147,12 @@ function connectSSE(): void {
150147
});
151148

152149
res.on('end', () => {
153-
sseConnected = false;
154-
sseReconnectTimer = setTimeout(connectSSE, 3000);
150+
setTimeout(connectSSE, 3000);
155151
});
156152
});
157153

158154
req.on('error', () => {
159-
sseConnected = false;
160-
sseReconnectTimer = setTimeout(connectSSE, 5000);
155+
setTimeout(connectSSE, 5000);
161156
});
162157
}
163158

src/renderer/renderer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4913,7 +4913,6 @@ function renderFolderSearchResults(pattern: string, cancelled?: boolean): void {
49134913
`;
49144914

49154915
const items = matches.map((match, index) => {
4916-
const relPath = match.filePath;
49174916
const lineText = match.lineText.length > 200 ? match.lineText.substring(0, 200) + '...' : match.lineText;
49184917

49194918
return `

src/tests/baseline.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ describe('BaselineStore', () => {
165165
const id = store.save('test', '', [], fp);
166166
const before = store.get(id)!.updatedAt;
167167

168-
// Small delay to ensure different timestamp
169-
const future = Date.now() + 100;
170168
store.update(id, { name: 'updated' });
171169
const after = store.get(id)!.updatedAt;
172170
expect(after).toBeGreaterThanOrEqual(before);

src/tests/benchmark.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ describe('Logan Benchmark', () => {
155155
it(`should index ${size.label}`, async () => {
156156
const filePath = path.join(BENCH_DIR, `bench_${size.lines}.log`);
157157
const handler = new FileHandler();
158-
const stat = fs.statSync(filePath);
159-
160158
global.gc?.(); // Optional GC before measuring
161159
const memBefore = getMemoryMB();
162160
const start = performance.now();

src/tests/serial.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('FileHandler.indexNewLines', () => {
8383

8484
// Append the rest + a new line
8585
fs.appendFileSync(tempFile, '-complete\nline3\n');
86-
const newLines = handler.indexNewLines();
86+
handler.indexNewLines();
8787
// The previous 'partial' line gets extended to 'partial-complete', plus 'line3'
8888
// So net new lines = 2 (re-parsed partial + new line3), but since the old 'partial'
8989
// was already counted, the total should be 3
@@ -446,7 +446,6 @@ describe('Wall clock timestamp prepending in serial data', () => {
446446
});
447447

448448
it('should produce timestamps that time-gap detection can parse', async () => {
449-
const buf = { value: '' };
450449
const handler = new FileHandler();
451450

452451
try {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"strict": true,
99
"noImplicitReturns": true,
1010
"noFallthroughCasesInSwitch": true,
11+
"noUnusedLocals": true,
1112
"esModuleInterop": true,
1213
"skipLibCheck": true,
1314
"forceConsistentCasingInFileNames": true,

0 commit comments

Comments
 (0)