Skip to main content

avoid-unused-generics

added in: 1.4.0
🛠

Warns when a function or method declares unused generic types.

Example

❌ Bad:

class SomeClass {
// LINT
String unused<T extends num>() {
// ...
}

// LINT
String multiple<T, U>(U param) {
// ...
}
}

// LINT
void function<T>() {
return;
}

✅ Good:

class SomeClass {
String used<T extends num>() {
return (value as T).toString();
}

T multiple<T, U>(U param) {
// ...
}
}

void function() {
return;
}