Skip to content

Duplicated fixes if 2 imports are unused #60365

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
gryznar opened this issue Mar 19, 2025 · 10 comments
Closed

Duplicated fixes if 2 imports are unused #60365

gryznar opened this issue Mar 19, 2025 · 10 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@gryznar
Copy link

gryznar commented Mar 19, 2025

  1. Prepare
    Image

  2. Right click on any warning

Result

Image

  • fixes are duplicated
  • "unused" and "shown" are not properly separated
@gryznar gryznar added the legacy-area-analyzer Use area-devexp instead. label Mar 19, 2025
@srawlins srawlins added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) 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 Mar 19, 2025
@srawlins
Copy link
Member

CC @FMorschel

@gryznar
Copy link
Author

gryznar commented Mar 19, 2025

As a side note: it will be very handy to automatically remove all unused / duplicated imports at once. Currently, every case requires manual fix. IntelliJ has an option to optimize imports while reformatting, but this is verry buggy

@FMorschel
Copy link
Contributor

it will be very handy to automatically remove all unused / duplicated imports at once

IIRC, Organize Imports should do that, but I also agree we should probably review this fix.

@gryznar
Copy link
Author

gryznar commented Mar 19, 2025

I've checked organize imports and it does not handle duplicated imports if I remember correctly. Also it fixes once at a time

@gryznar
Copy link
Author

gryznar commented Mar 19, 2025

Btw, comming from Python, Dart with its analyzer, builtin linter and formatter is totally great IMO. Thank you for your great work!

@FMorschel
Copy link
Contributor

I've just tested:

import 'dart:math' show max, min, Random;

Random? r;

In Dart 3.8.0-edge.151edd1aabe115e8b204918f038a93e7ff5b63b2 (2025-03-17) and I can't see this neither in VS Code or IntelliJ.

Image

Image

Image

Can you share a repro and the version you found this bug? On this version, I can also use Organize Imports to fix both diagnostics at once.

@gryznar
Copy link
Author

gryznar commented Mar 19, 2025

Ah, so this was fixed recently. Sorry for confusing. I am using latest stable: 3.7.2

@FMorschel
Copy link
Contributor

It's fine! Always better to notify than to have bugs. Is there anything else this issue should address? Or can we close it? If there is nothing else feel free to close this. I'm not from the team so I can't do that.

P.S.: Fixes/assists can always be tested on main at dartpad.dev if you change the channel below on the page.

P.S. 2: I found this:

@gryznar
Copy link
Author

gryznar commented Mar 20, 2025

Yet another case come into my mind, but this may be not possible to achieve. IntelliJ has "Optimize imports" flag (available under "alt+shift+l") and if it could be joined with "organize imports", it will be perfect. But I am aware that it can be outside control.

The issue may be closed. Thank you once again and sorry for this whole churn

@gryznar gryznar closed this as completed Mar 20, 2025
@FMorschel
Copy link
Contributor

I'm not aware if they have a tracker on GH or only on YouTrack.

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. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants