R23WARNINGfunction

Default Value Changed

Flags when a parameter's default value is modified. Callers omitting this argument will silently receive different behavior.


Applies to

TypeScriptPythonGoJavaRust

Why it matters

Changing a default value is not a compilation error — it is a silent behavioral change. Callers that rely on the old default will get different results without any warning at compile time. This makes it one of the most dangerous "non-breaking" changes.

Example

Before (default: 3)
// retry.ts
export function fetchWithRetry(
  url: string,
  retries: number = 3  // retries up to 3 times
): Promise<Response> { ... }
After (default: 1)
// retry.ts (WARNING — default changed)
export function fetchWithRetry(
  url: string,
  retries: number = 1  // now only retries once
): Promise<Response> { ... }

What you see in the terminal

$ npx dg check

  [WARNING] fetchWithRetry (signature_change)
  src/retry.ts:3
  Default value for parameter 'retries' changed from '3' to '1'. Callers omitting this argument will receive different behavior.

How detection works

The classifier compares the defaultValue field of each parameter. If both old and new have a default value and they differ, the rule fires with warning severity.

Real-world scenario

A team reduces the default retry count from 3 to 1 to reduce latency. Any service calling `fetchWithRetry(url)` without specifying retries will now fail faster, potentially causing cascading failures in production.

Edge cases

  • Default value comparison is text-based — equivalent expressions like '3' and '2+1' are treated as different
  • Removing a default value entirely (making the param required) is handled by R03