Skip to content

Commit 190fa0b

Browse files
sjsyrekclaude
andcommitted
refactor(cache): remove dead code for undefined marker check (Issue #7)
Removed unreachable code in CacheService.get() method. Analysis: - CacheService.set() prevents undefined from being cached (Issue #10 fix) - Therefore, get() will never encounter '__UNDEFINED__' marker - Removed 4 lines of dead code checking for this marker Code Removed: ```typescript // Check for undefined marker if (row.value === '__UNDEFINED__') { return undefined; } ``` Replaced With: - Clarifying comment explaining undefined values are never cached - Direct JSON.parse() without unnecessary check Impact: - Cleaner, more maintainable code - Eliminates confusion about undefined handling - Removes unreachable code path - All 1454 tests still passing CHANGELOG.md updated with refactoring details. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a442194 commit 190fa0b

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6464
- **Example Attack Prevented**: User creating symlink to `/etc/passwd` and attempting to translate it
6565
- Location: `src/cli/commands/translate.ts:118-149` (translate method with lstatSync check)
6666

67+
### Refactoring
68+
- **Dead Code Removal: Undefined Marker** - Cleaned up unreachable code (Issue #7)
69+
- Removed undefined marker check from CacheService.get() method
70+
- Check was dead code: undefined values are never cached (Issue #10 fix prevents caching undefined)
71+
- Removed lines checking `if (row.value === '__UNDEFINED__')`
72+
- Added clarifying comment explaining why check is unnecessary
73+
- **Impact**: Cleaner, more maintainable code; removes confusion about undefined handling
74+
- **Code Quality**: Eliminates unreachable code path that could never be executed
75+
- Location: `src/storage/cache.ts:150-152` (get method, removed dead code check)
76+
6777
### Fixed
6878
- **Critical: Duplicate text handling in batch translation** - Fixed data loss bug for duplicate inputs
6979
- When input array contained duplicate texts (e.g., `["Hello", "Hello", "World"]`), only the last occurrence received translation

src/storage/cache.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,8 @@ export class CacheService {
147147
return null;
148148
}
149149

150-
// Check for undefined marker
151-
if (row.value === '__UNDEFINED__') {
152-
return undefined;
153-
}
154-
150+
// Parse cached value (Issue #7: undefined marker check removed as dead code)
151+
// Undefined values are never cached (see set() method Issue #10)
155152
try {
156153
return JSON.parse(row.value) as unknown;
157154
} catch (error) {

0 commit comments

Comments
 (0)