Not all transitive references are corrected by require_explicit_imports
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
Describe the bug
We use require_explicit_imports: true, and have some found some cases where SwiftLint does not add imports for transitively used swift modules. The ones I've seen so far are:
- Use of functions defined on extensions, where the module that defines the
extensionis not directly imported by the module that references the extension - Calling functions that have parameters with default values, and where the function/initializer of the default is defined in a module not directly imported
- References to type metadata from modules not directly referenced. For example, one case was
self.mapView.rx.willMove, and the module that defines the type ofwillMovewas not being directly imported (it may also be relevant that the type ofwillMoveis a generic and it conformed to a protocol)
In these cases, if the import does exist, the unused_import rule will remove it, which prevents manual fixes.
The main purpose of this issue is to see if these have been discussed, and to see if these implicit references are visible from SourceKit. These cases were identified when switching to dynamic linking, instead of static linking.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the require_explicit_imports and unused_import rules, then investigate whether SourceKit exposes the transitive references described: extension functions, default-value functions or initializers, and type metadata. Done means documenting the findings and determining how implicit references should be handled without unused_import removing needed imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100