-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Analyzer doesn't warn me that I haven't included a dependency #25710
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
Comments
dup of #57175 |
This seems like more of an error than a lint. The only reason analyzer doesn't already create errors for this is because we only have one place to look to find the packages to resolve code against, even though pub defines two sets of packages. @munificent @nex3 Now that we have .packages files, it would theoretically be possible for pub to create one .packages file in the root directory of the project that contains both |
I'm not a big fan of that idea. The I think a better solution would be for the analyzer to go to the source and look at the pubspec. The format is very simple and stable. |
I disagree. The
Did you mean "we're moving away from putting
I don't understand what problem you're referring to. Could you elaborate? |
Okay, but the only way that resolution logic is applied is based on an entrypoint. There are no entrypoints in lib, and there's nothing in the
Yes, sorry.
If I write name: myapp
dependencies:
source_span: ^1.0.0
dependency_overrides:
source_span: {path: ../source_span} The |
True, but analyzer has to be a bit liberal in it's definition of "entry point" :-) in order to be useful in cases where there is no actual entry point, such as a reusable library. We take it to mean any Dart file in the package.
Seems to me that that's implied by the following portion of the look-up algorithm:
True, but analyzer is a development time tool, so it's only interested in the local view, which is what it gets when pub is run in the package containing the dependency override. |
If it's only interested in the local view, then why do you want to exclude dev dependencies? They're part of the local view too. Technically, as far as pub is concerned, they're a subset of dependency overrides. |
Sorry, I misspoke. There are more (possible) sets of package resolution information than I have terminology for. There is a difference between the packages that can validly be referenced inside 'lib' (dependencies) and the packages that can be referenced elsewhere (dependencies + dev dependencies). That defines two different sets of package resolution data and it's important to users so that they can be told if they reference things inside 'lib' that won't be valid when they publish their package. There is an orthogonal dimension, which is the package resolution data both with and without dependency overrides. (In my mind that makes four sets so far.) I don't think users care as much about this distinction and analyzer should just trust that the sets with dependency overrides are what users really wants their code to be analyzed against. It appears that I was misusing "local" when I used it to mean "with dependency overrides". (I'm still not sure which combinations you mean by "public" and "local".) |
How about we look at this a different way: Let's say the analyzer could show the user the warnings we're talking about here without adding an extra If we did that, and users were getting the warnings they wanted, would there be any additional value for users in having that extra My belief is that the answer is no. The file doesn't add end user value. It's just a communication channel between analyzer and pub. Given that, how about we pick a communication channel that doesn't clutter up their file system? If analyzer still uses list-package-dirs, we could add another key for dev_dependencies to that. Or we could add machine-readable output to |
It does, but only when it cannot find a Is there a package that contains the code pub uses to read pubspec.yaml files? I don't want to duplicate that code, but would be willing to use it. |
There's not, although we've considered factoring it out from pub before. It may be overkill in this case, though; the information you'd need is just |
We really need to do something to differentiate between these two bodies of code, but handling it correctly isn't going to be trivial. Given that it isn't stopping anyone from developing, it probably won't happen soon. |
This is a duplicate of a request in the linter. |
Duplicate of #57175 |
I have the following dependencies:
So I have not included path, however, I can just include path in my
lib
files.I think this is because my dev_dependencies depend on it. I think I should get an error, that I haven't included path in my dependencies. (when I use it in
lib
directory)The text was updated successfully, but these errors were encountered: