Rules
redline checks 137 things. Each rule below has its own page with the reason, the fix, examples it flags and leaves alone, and the research it comes from.
AI tells19
Placeholder instead of codeplaceholder-codeModels elide code with `// ... existing code ...` or `# implementation here`. When that lands in a commit, the real code is gone or was never written.
Stubbed implementationstub-bodyA function that only throws `not implemented` passes type checks and review, then fails in production on the first call.
Change-log commentchangelog-commentComments like `// Added retry` or `// now uses the new client` describe the diff, not the code. They are true for one commit and misleading forever after.
Chat voice in a commentassistant-voiceComments addressed to the person who asked for the change ('I've added', 'feel free to') are pasted from an assistant's answer. They say nothing about the code.
Deprecated APIstale-apiDeprecated APIs still work today and print warnings, change behavior or disappear in the next major version.
Floating model aliasfloating-modelAliases move to new snapshots without notice, so prompts, costs and outputs change with no code change.
Placeholder valueplaceholder-valueGenerated code ships with `YOUR_API_KEY` and `your-domain.com` in it. It runs, then fails at the first real request.
Versioned or boastful nameversioned-name`parseV2`, `fetchDataNew`, `enhancedSearch` mean a second copy was added beside the first instead of replacing it. Names should say what a thing does.
Comment repeats the coderestating-comment`// increment counter` above `counter++` doubles the reading and goes stale when the code changes. It's the most common AI comment.
Docstring restates the nameobvious-docstring'Get the user.' on `get_user` tells nothing new. Docstrings earn their place with units, edge cases and failure modes.
Em or en dashem-dashReaders now take the em dash as a sign nobody edited the text. In logs and UI strings it also breaks grep and plain-ASCII terminals.
Emoji in codeemojiEmoji in logs, comments and error messages are a common AI tell. They don't grep, some terminals render them as boxes, and they add no meaning a word wouldn't.
Filler commentfiller-comment'This function is responsible for…' and section labels like `// Imports` restate the structure a reader can already see. Models add them by reflex.
Generated summary filedoc-sprawlAgents leave `IMPLEMENTATION_SUMMARY.md` and `FIXES_REPORT.md` behind. They narrate one session and nobody updates them.
Marketing wordshype-wordsWords like robust, seamless and comprehensive are filler that models lean on. They make docs longer and say nothing checkable.
Numbered placeholder namenumbered-name`data2`, `result3` mean the author ran out of names. The reader has to trace where each one came from.
Numbered step commentsstep-comment`// Step 1:`, `// Step 2:` scaffolding is a tutorial habit. It goes stale when a step is added and hides the one comment that matters.
Section banner commentsection-banner`// ===== Helpers =====` banners split a file into chapters instead of splitting it into files. Models add them to look organised.
TODO left intodo-markerTODOs are where reviews hide unfinished work. They rarely get done and nobody owns them.
Error handling19
Bare exceptbare-except`except:` catches everything, including Ctrl-C and `sys.exit`, so the program can't even be stopped cleanly.
Empty catchempty-catchAn empty catch makes every failure look like success. The bug surfaces later and far away, with no trace of the cause.
Mutable default argumentmutable-defaultPython evaluates defaults once. A list or dict default is shared by every call, so state leaks between calls.
Rejection swallowedpromise-catch-noopAn empty `.catch` turns every failure into silent success. The bug shows up later, far from the cause, with no log.
Branches on error textmatch-error-messageError messages are for people and change without notice. A reworded message silently changes control flow.
Error turned into an empty valuecatch-returns-emptyReturning `null` or `[]` from a catch makes 'it failed' look like 'there was nothing'. The UI shows an empty list instead of an error.
except Exceptionbroad-exceptCatching `Exception` treats a typo, a None and a network error the same way. Bugs get handled as if they were expected failures.
Logs the error and carries onlog-and-continueLogging an error and continuing means the caller thinks it worked. The log line is the only witness, and nobody reads it in time.
Network call without a timeoutmissing-timeoutWithout a timeout one stuck upstream holds a worker until the process dies. At scale that becomes an outage.
Throws a non-Errorthrow-literalThrowing a string or object loses the stack trace and breaks `instanceof Error` checks in handlers.
assert used for validationassert-for-validationAsserts are for invariants in tests and debugging. Under `python -O` they are removed, so input validation built on them disappears.
Error caught and ignorederror-discardedA catch that never reads the error handles every failure the same way, including the ones you didn't expect.
Exits the processexit-in-libraryExiting deep in a call stack skips cleanup, loses buffered logs and makes the code impossible to reuse or test.
Fallback hides missing datasilent-defaultDefaulting to `[]`, `{}` or `''` makes a missing field look like an empty one. The bug surfaces later as wrong output, not as an error.
fetch without a timeoutfetch-without-timeout`fetch` has no default timeout. A hung upstream holds the request, the connection and the user until something else gives up.
Generic error messagegeneric-error-message'Something went wrong' tells the on-call engineer nothing. Good messages name the operation and the input that failed.
Raises plain Exceptionraise-bare-exceptionA generic exception forces callers into `except Exception`, which also catches real bugs.
Re-raise loses the causeraise-without-fromRaising a new exception inside `except` without `from` buries the original error in 'During handling…' noise.
Time without a time zonenaive-datetimeNaive datetimes compare wrongly with aware ones and shift when the server's zone or DST changes.
Type safety12
`is` with a literalis-literal`x is 1` or `x is 'a'` depends on interpreter caching. It can be true in tests and false in production.
Double castdouble-castA double cast is a lie to the type checker. It hides a real mismatch that will show up as a runtime bug.
`any` typeany-type`any` spreads: everything it touches stops being checked. A wrong field name or shape compiles fine and fails at runtime.
Lint or type check switched offlint-suppressEach suppression is a finding someone decided not to fix. They pile up, and the linter stops meaning anything.
Shapeless object typeloose-object-typeBags of `Record<string, unknown>` or `dict[str, Any]` move type errors from compile time to runtime and hide the real shape from readers.
Type error suppressedts-suppressSuppressed type errors are bugs the compiler already found. `@ts-ignore` also keeps hiding new errors on that line after the original is fixed.
`var`var-declaration`var` leaks out of blocks and can be used before it's assigned, which causes subtle loop and closure bugs.
Compares to None with ==none-compare`==` can be overridden by a class and gives surprising answers. `is None` is exact and idiomatic.
Loose equalityloose-equalityLoose equality follows coercion rules few people remember. It hides type bugs.
Non-null assertionnon-null-assertionNon-null assertions skip the check the type system asked for. They are often added to quiet an error, not because the value is proven present.
Optional chaining everywheredefensive-chainingChains like `a?.b?.c?.d` silence errors on data you should know the shape of. A missing field becomes `undefined` downstream instead of an error here.
TypeScript enumts-enumEnums generate objects, number enums accept any number, and they don't work with type-stripping runtimes.
Tests and CI16
Assertion that can't failtrivial-assertion`expect(true).toBe(true)` makes a test look green and covered while checking nothing. Models write these to make a failing test pass.
Check switched off in configgate-weakenedLoosening `strict` or skipping a CI job makes every later change easier to break, and the PR looks like a config tweak.
CI failure ignoredci-escape-hatchCI is only worth having if red means red. `|| true`, `continue-on-error` and `--no-verify` make failures look like success.
Exits from a testexit-in-testExiting with 0 from inside a test makes the runner report success no matter what ran or failed.
Focused testfocused-testA committed `.only` turns a whole suite green by not running it.
Mocks the code under testmock-of-subjectWhen a test mocks the module it's named after, it tests the mock. It will pass while the real code is broken.
Test-only branch in shipped codetest-branch-in-prodBranches on 'am I in a test?' mean the tests exercise a path production never takes.
Assertions removedassertions-removedDeleting assertions is the quickest way to make a red test green. Sometimes right, often the bug fix that wasn't.
Expects any errorbroad-raises`toThrow()` with no argument or `pytest.raises(Exception)` passes when the code fails for an unrelated reason, like a typo.
Fixed sleep in a testsleep-in-testSleeps make tests slow and flaky at once: they guess how long something takes instead of waiting for it.
Retries a flaky testtest-retryAuto-retries turn real races and order bugs into green builds. The flake is still there, now invisible.
Skipped testskipped-testSkipped tests are deleted tests that still look like coverage. They're how a red suite gets turned green without a fix.
Test without an assertionno-assertionA test with no assertion only checks that nothing throws. It stays green when the code returns the wrong answer.
Mockmock-heavyEvery mock is a place where the test checks your assumption about the other code instead of the code itself. Heavy mocking is how suites pass while production breaks.
Test named after a tickettest-named-for-history'fixes bug 1234' tells the next reader nothing when it fails. The name should say what must stay true.
Weak assertionweak-assertion'It returned something' passes for wrong answers too. These assertions inflate coverage without catching regressions.
Performance12
Await inside a loop (N+1)await-in-loopOne round trip per item makes the loop as slow as the list is long. With a database call inside, it's the classic N+1 query.
Awaits that could run togethersequential-awaitsEach await waits for the one before. When the second call doesn't need the first one's result, the latency adds up for nothing.
Deep copy through JSONjson-cloneThe JSON round-trip is a slow, lossy deep copy that silently changes types.
Quadratic reducespread-accumulator`{...acc, [k]: v}` inside reduce rebuilds the whole object each iteration. Fine for 10 items, a stall for 10,000.
Reads whole rowsselect-starWhole-row reads move columns nobody uses, defeat covering indexes, and pull large JSON or text columns off disk on every call. They get slower as the table grows.
Array scan inside a looplookup-in-loop`.find` or `.includes` inside a loop scans the array once per item: O(n²). Unnoticeable at 50 items, a freeze at 50,000.
Blocking file or process callsync-ioSync I/O in a server stops all concurrent work until the disk or child process returns.
f-string in a log callfstring-in-loggerf-strings run even when the level is off, and they defeat log grouping because every message is unique.
Parses a URL to read one partnew-url-parse`new URL()` allocates, parses and validates the whole string. On a hot path, repeated parsing adds up, and often the framework already gives you the parsed piece.
Reads one key out of a JSON columnjsonb-hot-readA large jsonb value is stored out of line. Reading one key decompresses all of it, so a query that returns a few KB can read gigabytes.
Regex built on every callregex-in-functionCompiling a regex costs far more than running it. Inside a function or loop, that cost repeats on every call.
Unbounded parallel callsunbounded-fanoutUnbounded fan-out exhausts connection pools, trips rate limits and can take down the service it calls.
Security22
Download piped to a shellpipe-to-shell`curl | sh` executes remote code with no review and no integrity check; a compromised host owns the machine.
evaleval-callIf any part of the string comes from input, this is remote code execution. Even when it doesn't, it defeats static analysis and CSP.
Invisible characterinvisible-charZero-width and bidi control characters can make code read differently from how it runs (the Trojan Source attack) and break string comparisons.
Secret in a public env varclient-exposed-secretPublic env prefixes inline the value into client JavaScript. A secret there is published.
Secret in sourcehardcoded-secretAnything committed is copied to every clone, fork and CI log, and stays in history after you delete it.
Secret with a fallback valuedefault-secretIf the variable is unset in production, the app quietly runs with a secret that's in the repo.
Secret written to a logsecret-in-logCredentials in logs end up in log search, vendor dashboards and support tickets, with weaker access control than the secret store.
Shell command from stringsshell-injectionA filename with `;` or `$()` in it becomes a second command. Shell parsing is the bug.
SQL built from stringssql-injectionString-built SQL is the textbook injection bug. Escaping by hand misses cases; parameters don't.
TLS verification offtls-offDisabled TLS verification is usually added to get past a dev certificate error and then ships.
Token decoded without verifyingjwt-unverifiedAnyone can write a JWT. Without signature verification, the claims (user id, role) are whatever the caller wants.
Unsafe deserializationunsafe-deserializePickle and full YAML loaders construct arbitrary objects. Loading untrusted bytes with them is code execution.
Archive extracted uncheckedtar-extractallArchive entries like `../../etc/cron.d/x` escape the destination (path traversal, 'tar slip').
Auth token in localStoragetoken-in-localstorageOne XSS bug, or one bad npm package, can read localStorage and take the session.
CORS open to every origincors-wildcardA wildcard origin lets any page in a user's browser read these responses. With credentials it's an account takeover path.
Math.random for a secretinsecure-random`Math.random` and `random` are seeded PRNGs; an attacker who sees a few outputs can predict the next.
Raw HTMLhtml-injectionRaw HTML bypasses the framework's escaping. One unescaped field is enough to run script in your users' sessions.
Request data in a file path or URLrequest-to-path`../` in a path reads files outside the folder; a user-chosen URL lets them make your server call internal services (SSRF).
Secret in a URLsecret-in-urlURLs are logged everywhere: load balancers, CDNs, analytics, referrer headers.
CI action not pinnedunpinned-actionTags can be moved to new code. A compromised action runs with your CI secrets.
target=_blank without reltarget-blankOlder browsers give the opened page a handle to yours (`window.opener`) that can redirect it.
Weak hashweak-hashMD5 and SHA-1 have practical collisions. Fine for cache keys, wrong for passwords, signatures or integrity checks.
Design19
Compatibility shimcompat-shimCompatibility layers and legacy aliases mean every reader has to learn both paths, and the old one never gets deleted.
Deep nestingdeep-nestingEvery nested `if` or loop is another condition to keep in mind. Past three or four, readers lose track of which case they're in.
Duplicated blockduplicate-blockCopy-pasted code drifts: a fix lands in one copy and not the other. Models duplicate rather than find the existing helper.
Long functionlong-functionLong functions mix several jobs. They're hard to name, test and change without breaking a part you didn't read.
Old/new switchfeature-toggleA toggle that keeps the old path alive doubles the states to test, and the old path rots because nobody runs it.
Pass-through wrapperpass-throughA function that only forwards its arguments adds a name to learn and a hop to follow, and hides nothing. Ousterhout calls this a shallow module.
Unreachable codeunreachable-codeCode after a `return` never runs. It misleads readers and usually means a merge or edit went wrong.
Boolean argumentsboolean-args`render(user, true, false)` hides intent and makes swapping two flags a silent bug.
else after returnelse-after-returnWhen the `if` branch returns, the `else` only adds indentation. Early returns keep the main path flat.
Environment read deep in codeenv-readScattered `process.env` reads make behavior depend on hidden globals, fail late on a typo, and can't be checked at startup.
globalglobal-statementHidden global state makes functions order-dependent and tests interfere with each other.
Long file grewlong-fileVery long files usually hold several modules. Every addition makes the split harder.
Long way round a builtinreinvented-builtin`.filter(...).length > 0` builds a whole array to answer yes/no; `range(len(x))` indexes by hand. The builtin is shorter and says what you mean.
Nested ternarynested-ternaryNested conditionals in one expression hide the branches and are easy to get wrong when edited.
New dependencynew-dependencyEvery dependency is code you ship, audit and upgrade forever. Models add packages for things the standard library already does.
Probes for a shapehasattr-probeFeature-probing your own objects means the types don't say what they hold. It usually covers two incompatible versions of a thing.
Temporary code with no endtemporary-codeTemporary code without an owner or an issue becomes permanent. Nobody remembers what it was waiting for.
Too many parametersmany-paramsLong positional parameter lists are easy to call in the wrong order and hard to extend.
utils / helpers modulejunk-drawer-module`utils.ts` grows forever because anything can go there. Names by topic (`dates.ts`, `money.py`) keep code findable and cohesive.
Async5
async callback in forEachasync-foreach`arr.forEach(async ...)` fires every callback and returns immediately. Rejections become unhandled and ordering is lost.
async Promise executorasync-promise-executorErrors thrown inside an async executor are lost; the outer promise hangs forever.
Blocking call in async codeblocking-in-asyncA blocking call inside `async def` freezes the event loop: every other request waits for this one.
Fixed wait in shipped codesleep-in-prodSleeps guess at timing. They are too short under load and pure latency the rest of the time, and they hide races instead of fixing them.
setTimeout(…, 0) timing hacktimeout-zeroZero-delay timeouts paper over a race: they work until something else also defers.
React5
Data fetching in useEffecteffect-fetchFetching in an effect races when props change quickly, double-fetches in Strict Mode and has no cache.
Index as React keyindex-as-keyWhen items move or are removed, index keys make React reuse the wrong component state; random keys remount every render.
useEffect without dependencieseffect-no-depsAn effect with no dependency array runs after every render. It's a common source of loops and wasted work.
Effect that copies into statederived-state-effectSetting state from an effect to mirror props or other state costs an extra render and drifts out of sync.
New object as context valueunstable-context-valueInline `value={{...}}` creates a fresh object each render; React sees a change and re-renders the whole subtree.
Hygiene8
Merge conflict markermerge-conflictConflict markers break the build in code and silently corrupt config, docs and data files.
Debug output left indebug-printDebug prints leak data into logs, cost I/O on hot paths and bury real log lines. `debugger` and `breakpoint()` stop the process.
Machine-specific pathuser-pathAbsolute home paths work on the author's laptop and nowhere else, and they leak usernames into the repo.
Unpinned dependencyunpinned-dependency`latest`, `*` and bare package names pull whatever is newest at install time, so a build can break with no change in the repo.
Wildcard importwildcard-importStar imports hide where names come from, shadow builtins and break when the other module adds a name.
Commented-out codecommented-out-codeDead code in comments confuses readers about what runs and never gets updated with the code around it.
Hard-coded localhostlocalhost-urlA localhost URL in production code works in development and fails everywhere else, usually silently.
Unnamed numbermagic-number`86400000` or `3500` means nothing at the call site. When it changes, someone has to find every copy.