Skip to main content

avoid-assigning-to-static-field

added in: 1.22.0
Pro+

Warns when an instance method assigns to a static field.

Example

❌ Bad:

class Some {
static int value = 1;

void work() {
value = 2; // LINT
}
}

✅ Good:

class Some {
static int value = 1;

static void work() {
value = 2;
}
}