linter icon indicating copy to clipboard operation
linter copied to clipboard

proposal: Check static members and enum members in `unreachable_from_main`

Open srawlins opened this issue 1 year ago • 1 comments

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.

srawlins avatar Aug 04 '22 15:08 srawlins

WDYT, @a14n ?

srawlins avatar Aug 10 '22 16:08 srawlins

:+1:

a14n avatar Sep 01 '22 15:09 a14n

Complete with https://github.com/dart-lang/linter/pull/3660

srawlins avatar Feb 08 '23 23:02 srawlins