R27BREAKINGenum

Enum Member Changed

Flags when an enum member is removed, renamed, or has its value changed. References to the removed member fail to compile, and value changes cause silent data corruption.


Applies to

TypeScriptJavaRust

Why it matters

Enum changes are especially dangerous because they often flow into databases and API payloads. If Status.Active = 1 changes to Status.Active = 0, every database record with the old value is now misinterpreted.

Example

Before
// status.ts
export enum PaymentStatus {
  Pending = 0,
  Active = 1,
  Failed = 2,
  Refunded = 3,
}

// database — stores numeric values
// Row: { userId: 42, status: 1 }  (means Active)
After (member removed, value collision)
// status.ts (BREAKING — member removed + value changed)
export enum PaymentStatus {
  Pending = 0,
  Processing = 1,  // value 1 was Active, now Processing
  Failed = 2,
  Refunded = 3,
}

// database — SILENT CORRUPTION
// Row: { userId: 42, status: 1 }  (was Active, now reads as Processing!)

What you see in the terminal

$ npx dg check

  [BREAKING] PaymentStatus (enum_member_changed)
  src/status.ts:2
  Enum member 'Active' was removed or renamed. Downstream consumers referencing this member will fail.

  [BREAKING] PaymentStatus (enum_member_changed)
  src/status.ts:4
  Enum member 'Processing' value changed. This may cause silent data corruption in existing records.

How detection works

The classifier iterates through the old enum's members: 1. If a member name is not found in the new enum — it was removed/renamed 2. If a member exists in both but the value changed — silent data corruption

New members added to the enum are safe (API expansion).

Real-world scenario

A team renames the `Active` enum member to `Processing` and assigns it the same numeric value. All code referencing `PaymentStatus.Active` breaks. Worse, historical database rows with value `1` now map to a different status meaning.

Edge cases

  • Adding a new member is safe — reported separately as symbol_added
  • Value changes are only flagged when both old and new have explicit values
  • In Rust, enum variants can carry data — structural changes are more complex