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

Add unused-imports tool #6

Merged
merged 20 commits into from
Apr 5, 2023
Merged

Add unused-imports tool #6

merged 20 commits into from
Apr 5, 2023

Conversation

keith
Copy link
Member

@keith keith commented Mar 28, 2023

This tool uses the index data to suggest imports that can be removed
from your files. Currently compared to SwiftLint's implementation it's
much faster, but doesn't yet add missing imports, or remove unused
system imports.

It's currently lightly affected by upstream issues listed here
#5

Todos:

  • Need to add some way to ignore files and maybe modules, we do this for generated files we don't want the tool to analyze, and third parties that we pull in
  • Potentially we want to add missing imports as well as removing invalid ones. this might be required because if you remove an invalid import that was polluting one you actually need, if you don't add the needed one here it will require manual work to add instead, also swiftlint does this so otherwise it's a bit of a regression
  • handle system imports, right now the indexes ive been testing with don't even have info for system modules, so maybe it would just work if i included those as well, but i believe swiftlint handles this too, so otherwise it would be a regression, although the value of removing system imports is much lower than removing your own imports
  • Test against swiftlint's removals, I haven't tested to see if this has any false-negatives that swiftlint doesnt
  • FIXMEs in code
  • Parallelize (probably v2)

@keith
Copy link
Member Author

keith commented Mar 28, 2023

cc @jpsim @codeman9 @marcosgriselli

@keith
Copy link
Member Author

keith commented Mar 28, 2023

for comparison we run swiftlint's logic sharded and it takes ~15 hours of machine time. The current implementation here takes ~20 seconds

codeman9
codeman9 previously approved these changes Mar 28, 2023
@keith keith force-pushed the ks/add-unused-imports-tool branch from 6e173e1 to b40a012 Compare March 29, 2023 22:42
@keith
Copy link
Member Author

keith commented Apr 4, 2023

Ok i think this is good enough to merge, the checks that aren't done can be done as follow ups and will be more understandable at this point. if you try this and find any issues let me know!

@keith keith marked this pull request as ready for review April 4, 2023 23:42
@keith keith enabled auto-merge (squash) April 4, 2023 23:43
sberrevoets
sberrevoets previously approved these changes Apr 5, 2023
keith added 6 commits April 5, 2023 11:44
This tool uses the index data to suggest imports that can be removed
from your files. Currently compared to SwiftLint's implementation it's
much faster, but doesn't yet add missing imports, or remove unused
system imports.

It's currently lightly affected by upstream issues listed here
#5
@keith keith force-pushed the ks/add-unused-imports-tool branch from cde3a78 to c516990 Compare April 5, 2023 18:44
@keith keith requested a review from sberrevoets April 5, 2023 18:53
@keith keith merged commit 1921fc1 into main Apr 5, 2023
@keith keith deleted the ks/add-unused-imports-tool branch April 5, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants