Skip to content

Add redundant internal and fileprivate accessibility analysis#1132

Open
danwood wants to merge 3 commits into
peripheryapp:masterfrom
danwood:redundant-internal-fileprivate
Open

Add redundant internal and fileprivate accessibility analysis#1132
danwood wants to merge 3 commits into
peripheryapp:masterfrom
danwood:redundant-internal-fileprivate

Conversation

@danwood

@danwood danwood commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Supersedes #1042 (same change, moved off my fork's master branch and rebuilt as a clean series on current master — that PR's CI failures came from a stale branch state that no longer compiled).

Follow-up to #976, which added --redundant-internal-accessibility and --redundant-fileprivate-accessibility alongside the existing redundant-public analysis. This revision handles implicit internal declarations and addresses the corner cases I hit while running it against a large codebase:

  • Cross-type fileprivate access within the same file
  • Enum cases (no longer suggested as private)
  • Internal types exposed through return types and stored properties of more visible declarations
  • Protocol requirement members and external protocol conformances
  • @NSApplicationDelegateAdaptor / @UIApplicationDelegateAdaptor delegate classes (must match the access level of the property that references them)
  • #Preview blocks
  • Stored-property reads that the index store attributes to implicit accessor children rather than the property itself
  • Declarations whose index-store position lands on a modifier keyword (e.g. static let) rather than the identifier

One open question carried over from #1042: this adds two new flags, and #1048 / #599 would imply more. If you'd rather consolidate (e.g. a single --redundant-accessibility flag with levels), I'm happy to rework the interface before this lands.

danwood added 3 commits June 12, 2026 18:44
Extends the existing redundant-public analysis with two new options,
--redundant-internal-accessibility and --redundant-fileprivate-accessibility,
reporting declarations whose explicit (or implicit) access level is broader
than their actual usage requires.

Handles implicit internal, cross-type fileprivate access, enum cases,
internal types exposed through return types and stored properties,
protocol requirement members, external protocol conformances,
@NSApplicationDelegateAdaptor/@UIApplicationDelegateAdaptor delegate
classes, and #Preview blocks. Stored-property reads emitted against
implicit accessor children are now followed when determining cross-file
usage, and declarations preceded by modifiers (e.g. static let) receive
their syntax metadata even when the index store records them at the
modifier keyword position.
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.

1 participant