Skip to content
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

Analyzer should provide a hint if an indirect package dependency is directly imported. #18804

Closed
stereotype441 opened this issue May 13, 2014 · 6 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@stereotype441
Copy link
Member

If the pubspec.yaml file specifies package A but not package B, and package A depends on package B, then pub will download package B into the "packages" directory (since it is an indirect dependency), and the user may import files from package B without error.

However, this creates a dangerous situation: if, in a later release of package A, the dependency on package B is dropped, then pub will stop downloading package B, and the user's code will break.

This exact situation recently occurred in the "analysis_server" project: in r35374, I started using the "mock" package to write analysis_server tests. Since analysis_server already contained a reference to "unittest" in its pubspec.yaml file, I was able to import 'package:mock/mock.dart' without any errors, warnings, or hints.

However, when unittest was upgraded to version 0.11.0, its dependency on mock was dropped, causing analysis_server to break the next time pub was run, in spite of the fact that analysis_server wasn't using any deprecated unittest features.

It would be nice if the analyzer provided a hint in this situation, to alert the user that they are making a direct import of a package that is an implicit dependency. The quick fix would be to add a clause to the pubspec.yaml file to make the dependency explicit.

@bwilkerson
Copy link
Member

Added this to the Later milestone.
Removed Type-Defect, Priority-Unassigned labels.
Added Type-Enhancement, Priority-Medium labels.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@stereotype441 stereotype441 added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@srawlins
Copy link
Member

Maybe for the linter, which also has other pubspec lints?

@bwilkerson bwilkerson added analyzer-linter Issues with the analyzer's support for the linter package and removed analyzer-warning Issues with the analyzer's Warning codes labels Apr 20, 2016
@zoechi
Copy link
Contributor

zoechi commented Apr 21, 2016

#57175
#57176

@srawlins
Copy link
Member

Replaced with linter requests, as pointed out by @zoechi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants