Add redundant internal and fileprivate accessibility analysis#1132
Open
danwood wants to merge 3 commits into
Open
Add redundant internal and fileprivate accessibility analysis#1132danwood wants to merge 3 commits into
danwood wants to merge 3 commits into
Conversation
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.
f1d42ba to
f883763
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-accessibilityand--redundant-fileprivate-accessibilityalongside 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:@NSApplicationDelegateAdaptor/@UIApplicationDelegateAdaptordelegate classes (must match the access level of the property that references them)#Previewblocksstatic let) rather than the identifierOne 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-accessibilityflag with levels), I'm happy to rework the interface before this lands.