Skip to content

improve analyzer hint when (incorrectly) using relative paths to reach out of the lib folder #24372

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
sigmundch opened this issue Sep 17, 2015 · 2 comments
Labels
devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead.

Comments

@sigmundch
Copy link
Member

I was going to request that we warn people if they try to import something outside of the lib/ folder in a package. For example:

// this is lib/foo.dart
import '../bar.dart'; // hint a problem here

I was pleasantly surprised that we are already giving an error in this case, the error however is not entirely clear. This is what we currently get:

Analyzing [foo.dart]...
[error] Target of URI does not exist: '../bar.dart' (/path/to/foo.dart, line 8, col 8)
1 error found.

Could we adjust the error message to say why? For example:

Analyzing [foo.dart]...
[error] Target of URI '../bar.dart' cannot be accessed from within your `lib` folder.
This relative import will fail if you ever import `foo.dart` from a package-URI
(/path/to/foo.dart, line 8, col 8)

1 error found.
@sigmundch sigmundch added Type-Defect devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead. labels Sep 17, 2015
@bwilkerson
Copy link
Member

I just created a test project of the form:

testProject
  bar.dart
  lib
    foo.dart

And added the import above in foo.dart. I don't see any error, warning or hint. Are you sure the file bar.dart really exists?

In any case, I think this is a duplicate of #22079.

@sigmundch
Copy link
Member Author

mmm, strange. I was using the analyzer_cli, but I agree - seems to match exactly that bug. Thanks for deduping :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

2 participants