no-duplicate-string

ProComplexity

Flag string literals duplicated too many times to catch AI copy-paste patterns

no-duplicate-string

Flag string literals duplicated too many times to catch AI copy-paste patterns

Category: Complexity | Tier: Pro

Why This Matters

AI repeats the same string literal throughout the codebase instead of extracting it into a constant. When that string needs to change, you have to find and update every occurrence, risking inconsistencies.

Bad Code

// Same string repeated throughout the codebase
app.get('/api/users', handler1);
app.post('/api/users', handler2);
app.put('/api/users', handler3);
app.delete('/api/users', handler4);

Good Code

// Extract repeated strings into constants
const USERS_ENDPOINT = '/api/users';
app.get(USERS_ENDPOINT, handler1);
app.post(USERS_ENDPOINT, handler2);

Configuration

This rule wraps sonarjs/no-duplicate-string. See upstream documentation for full configuration options.