R17BREAKINGfunctionStatic Changed
Flags when a method changes between static and instance (or vice versa). All call sites need to change syntax.
Applies to
TypeScriptJava
Why it matters
Static methods are called on the class (
MyClass.create()), while instance methods require an object (obj.create()). Changing between the two invalidates all call sites.Example
Before (static)
// factory.ts
export class UserFactory {
static create(name: string): User {
return new User(name);
}
}
// caller
const user = UserFactory.create("Alice");After (instance method)
// factory.ts (BREAKING)
export class UserFactory {
create(name: string): User {
return new User(name);
}
}
// caller — NOW BROKEN
const user = UserFactory.create("Alice"); // ERROR: not a static methodWhat you see in the terminal
$ npx dg check
[BREAKING] create (signature_change)
src/factory.ts:3
Method changed from static to instance. Call site syntax must change.How detection works
The classifier compares the isStatic flag on both signatures.
Real-world scenario
A factory pattern is refactored from static methods to instance methods for dependency injection. All callers using the static syntax will break.
Edge cases
- Only relevant in class-based languages (TypeScript, Java)
- In Go, this is the difference between a function and a method with a receiver