Skip to content

proposal: Check static members and enum members in unreachable_from_main #58812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks
srawlins opened this issue Aug 4, 2022 · 3 comments
Closed
5 tasks
Assignees
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-proposal linter-status-pending P3 A lower priority bug or feature request

Comments

@srawlins
Copy link
Member

srawlins commented Aug 4, 2022

unreachable_from_main

Description

The description does not need to change.

Details

As implemented now (in dart-archive/linter#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
Copy link
Member Author

WDYT, @a14n ?

@a14n
Copy link
Contributor

a14n commented Sep 1, 2022

👍

@srawlins srawlins self-assigned this Sep 1, 2022
@srawlins srawlins added the P3 A lower priority bug or feature request label Nov 28, 2022
@srawlins
Copy link
Member Author

srawlins commented Feb 8, 2023

Complete with dart-archive/linter#3660

@srawlins srawlins closed this as completed Feb 8, 2023
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-proposal linter-status-pending P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants