Unused import detection

Given that there is now a command to inspect implicit dependencies, would it make sense to also have one to detect unused dependencies?

Set intersection is used within the implicit-dependencies command to find implicit dependencies. (InspectImplicitImportsService.swift)

let implicitImports = sourceDependencies.intersection(allTargetNames).subtracting(explicitTargetDependencies)

Could we do something similar to find unused dependencies?

let unusedImports = explicitTargetDependencies.subtracting(sourceDependencies)

Hey @chris!

Yes, this is definitely a need :relieved:

There’s a PR in-progress to implement exactly that by @rofle100lvl.

1 Like