redline
LowError handlingsilent-default

Fallback hides missing data

Fallback hides missing data. Falls back to an empty value (?? []). If the data is missing by mistake, this hides it.

This is how the comment reads inline, under the flagged line.

Why it matters

Defaulting to [], {} or '' makes a missing field look like an empty one. The bug surfaces later as wrong output, not as an error.

What to do

Fail loudly when the field is required; default only where empty is a real, expected value.

Examples

Flagged
const items = order.items ?? [];
Better
const items = order.items; // required by the schema

What it catches

It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.

Flagged

const a = b ?? [];
src/app.py
x = d.get('k', '')

Left alone

const a = b ?? defaultItems;

Research

Fallbacks and guards that hide missing data (`?? []`, `.get(k, "")`, `hasattr` probes, catch that returns empty, long `?.` chains). A timeout looks like an empty result, and broken assumptions travel downstream.

Turn it off or change it

In a config file for the CLI, or in the API's rules field:

{
  "rules": {
    "disable": [
      "silent-default"
    ],
    "severity": {
      "silent-default": "medium"
    }
  }
}

Read the source or report a false positive.