Skip to content

Request for lint: unnecessary_dynamic #58082

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

Open
davidmorgan opened this issue Dec 11, 2019 · 1 comment
Open

Request for lint: unnecessary_dynamic #58082

davidmorgan opened this issue Dec 11, 2019 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-lint-request P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@davidmorgan
Copy link
Contributor

How about a lint that fires when you write dynamic for a parameter type but Object would have worked?

e.g.

void foo(dynamic bar) {
  if (bar is String) {
    ...
  } else if (bar is int) {
    ...
  } else throw UnsupportedError();
}

I see this pretty frequently and I think it hides a misunderstanding about what dynamic is useful for, i.e. for the rare cases when you want to turn off static checking and always do dynamic dispatch.

Happy to take a shot at implementing this if you think it makes sense, particularly if you can give hints about how to figure out whether dynamic dispatch was used :)

Thanks!

@davidmorgan davidmorgan added type-enhancement A request for a change that isn't a bug linter-lint-request labels Dec 11, 2019
@bwilkerson
Copy link
Member

@leafpetersen @srawlins
I know that we were, at one point, looking to define a coherent set of options related to uses of dynamic, but I don't know whether this would have been covered or what the current status of that work is. Is that still planned?

Should something like this be implemented as a lint, or would it be covered by the mechanisms above?

@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
@pq pq added the P3 A lower priority bug or feature request label Nov 20, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-lint-request P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants