redline
MediumDesignfeature-toggle

Old/new switch

Old/new switch. A switch between two code paths (process.env.USE_NEW_PARSER). Both paths now have to work and be tested.

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

Why it matters

A toggle that keeps the old path alive doubles the states to test, and the old path rots because nobody runs it.

What to do

Cut over: move every caller to the new path and delete the old one and the switch.

Examples

Flagged
if (process.env.USE_NEW_PARSER) { parseNew(x) } else { parse(x) }
Better
parse(x)

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

if (process.env.USE_NEW_PARSER) {}
src/app.py
if os.environ.get('ENABLE_V2'):
    pass

Left alone

if (process.env.NODE_ENV) {}

Research

Compatibility shims and old/new switches kept beside the replacement. Two paths double the places a bug can live, and the old one is never tested.

Turn it off or change it

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

{
  "rules": {
    "disable": [
      "feature-toggle"
    ],
    "severity": {
      "feature-toggle": "low"
    }
  }
}

Read the source or report a false positive.