linter
linter copied to clipboard
proposal: Check static members and enum members in `unreachable_from_main`
unreachable_from_main
Description
The description does not need to change.
Details
As implemented now (in https://github.com/dart-lang/linter/pull/3513), unreachable_from_main
only checks top-level members. It would be great to extend this to a few more things before removing the experimental
bit.
- unreachable public static members on public classes, mixins, enums, and extensions
- unreachable public instance members on public enums, including values, methods, getters, setters, operators
It would be great to report unreachable instance members of elements which participate in inheritance, but there is a lot more nuance involved, and risk for bugs. I don't feel strongly about it.
Kind
Unchanged
Good Examples
class C {
static int i = 7;
}
void main() => print(C.i);
Bad Examples
class C {
static int i = 7;
}
enum E {
one, two;
int i = 7;
}
Discussion
Discussion checklist
- [ ] List any existing rules this proposal modifies, complements, overlaps or conflicts with.
- [ ] List any relevant issues (reported here, the SDK Tracker, or elsewhere).
- [ ] If there's any prior art (e.g., in other linters), please add references here.
- [ ] If this proposal corresponds to Effective Dart or Flutter Style Guide advice, please call it out. (If there isn’t any corresponding advice, should there be?)
- [ ] If this proposal is motivated by real-world examples, please provide as many details as you can. Demonstrating potential impact is especially valuable.
WDYT, @a14n ?
:+1:
Complete with https://github.com/dart-lang/linter/pull/3660