-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove unused imports is not "across files" #57142
Comments
Summary: The |
Which directory were you in when you ran If that wasn't the problem, then I don't know what the issue is, but it's a bug for it to have not fixed code in the
I'm not sure what you mean by "fixing that as well." If you mean imports in test files, then the answer is that they should be fixed in the same phase as imports in any other file. Otherwise, please clarify. |
Nice question. I simulated it and it was fixed on the tests. I may have changed the directory to
Yes, thanks. But I guess my real question here is:
What is this "distinct import cleanup fix phase"? I don't think it was clear enough for me to understand. |
In case it's useful, you can pass the target directory on the command-line. That would allow you to write a script to run
The After this it performs one more analysis looking for unused imports and applies those fixes all in the final phase. The reason it's a separate phase is because a fix in one iteration can make an import be unused while a fix in a subsequent phase can cause it to be used again. To reduce the total amount of work being done and the chance of conflicting edits from one iteration to the next, we moved that work to happen once at the end. |
I see. Thanks for answering everything! |
I see that
RemoveUnusedImport
fromanalysis_server\lib\src\services\correction\dart\remove_unused_import.dart
has theCorrectionApplicability.acrossSingleFile
and this is the comment:I had a project with multiple unused imports because I added an export. And now multiple files had this warning - a single unused import each.
VS Code problems tab had no option to fix them all at once so I ran the CLI
dart fix
and almost everything got fixed but my tests (I'm unsure why I could not fix anything there even though myanalysis_option
says nothing about ignoring them (working on a package).What can we do about this? The above comment tells me nothing about what other phase is fixing that as well.
The text was updated successfully, but these errors were encountered: