Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
df85dab
Initial commit adding redundant internal and redundant fileprivate ac…
danwood Jul 25, 2025
2a81ffb
Update Sources/PeripheryKit/Results/OutputFormatter.swift
danwood Dec 15, 2025
c06d245
remove some stuff Ian noticed in my PR
danwood Dec 15, 2025
369eaf8
remove ‘referencedFiles’ which I’m no longer needing
danwood Dec 15, 2025
88a22e9
Redoing tests - WIP - moving into same module and rearranging
danwood Dec 15, 2025
2350efe
Redo tests, found bug in source graph
danwood Dec 15, 2025
eb1b20d
Remove files that got moved
danwood Dec 15, 2025
55e4262
Revert "Remove files that got moved"
danwood Dec 30, 2025
aa7cc4b
remove old inline failure warning
danwood Dec 30, 2025
7d06348
try to deal with most of the warnings from `mise r scan`
danwood Dec 31, 2025
c027b2f
take out specifier completely to make `mise` happy
danwood Jan 1, 2026
8f40db2
After running `mise r lint` and `mise r gen-bazel-rules`
danwood Jan 1, 2026
668fce8
restore paths to be fileprivate, since we were getting false positive.
danwood Jan 1, 2026
53231a6
readme update
danwood Jan 2, 2026
7d3ff81
A bit more documentation
danwood Jan 2, 2026
773c53c
Handle implicit internal, fix false positives and false negatives, re…
danwood Jan 7, 2026
86f8271
Fix accessibility warnings throughout the code base so that `mise r s…
danwood Jan 7, 2026
14d3698
Fix false positives caught by CI/Bazel building
danwood Jan 7, 2026
2f8c785
Make new function be private, conforming to new code
danwood Jan 12, 2026
f5d8529
Update to work with upstream changes, fixing external protocol check …
danwood Jan 20, 2026
4c3118f
Make sure that internal types used as return types of functions calle…
danwood Jan 24, 2026
53f037c
don’t mark enum cases as needing to be private; fix fileprivate detec…
danwood Jan 25, 2026
560c791
Fix checking against an external protocol
danwood Jan 25, 2026
a0fa75d
stored property type transitive exposure
danwood Jan 25, 2026
5532f96
Fix more problems with same file
danwood Jan 26, 2026
31b83b5
fix warning we found for newly introduced upstream property
danwood Jan 26, 2026
67ec334
Don’t mark #Preview blocks as fileprivate
danwood Jan 29, 2026
2638a45
For when retainSwiftUIPreviews, fix the detection of #Preview macro
danwood Jan 29, 2026
3c13a4a
solve some obscure false positive corner cases
danwood Jan 29, 2026
925d154
correctly mark children of symbol
danwood Jan 31, 2026
f7a3996
Refactor
danwood Feb 1, 2026
9f20d85
Fix false positive redundant fileprivate on stored properties accesse…
danwood May 27, 2026
e592cca
Fix false positive: AppDelegate flagged as redundant-internal when us…
danwood May 27, 2026
aa9df5a
Fix: @NSApplicationDelegateAdaptor search falls back to all types for…
danwood May 27, 2026
13b5044
Fix false positives: SwiftUI entry points, let-binding assign-only, N…
danwood May 29, 2026
d21b395
Skip unresolvable subproject file references instead of throwing
danwood Jun 1, 2026
d763b7a
Fix false positive: nested enum used as stored-property type not mark…
danwood Jun 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ jobs:
run: ${{ env.swift_build }}
- name: Scan
run: ${{ env.periphery_scan }} ${{ matrix.baseline && format('--baseline baselines/{0}', matrix.baseline) || '' }}
- name: Clean SwiftPM cache
run: rm -rf ~/Library/Caches/org.swift.swiftpm
- name: Test
run: ${{ env.swift_test }}
linux:
Expand Down Expand Up @@ -169,5 +171,7 @@ jobs:
run: ${{ env.swift_build }}
- name: Scan
run: ${{ env.periphery_scan }} --baseline baselines/linux.json
- name: Clean SwiftPM cache
run: rm -rf ~/.cache/org.swift.swiftpm
- name: Test
run: ${{ env.swift_test }}
373 changes: 83 additions & 290 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- [Enumerations](#enumerations)
- [Assign-only Properties](#assign-only-properties)
- [Redundant Public Accessibility](#redundant-public-accessibility)
- [Redundant Internal Accessibility](#redundant-internal-accessibility)
- [Redundant Fileprivate Accessibility](#redundant-fileprivate-accessibility)
- [Unused Imports](#unused-imports)
- [Objective-C](#objective-c)
- [Codable](#codable)
Expand Down Expand Up @@ -293,6 +295,18 @@ Declarations that are marked `public` yet are not referenced from outside their

This analysis can be disabled with `--disable-redundant-public-analysis`.

### Redundant Internal Accessibility

Declarations that are marked `internal` (or are unmarked, since this is Swift's default access level), yet are not referenced outside the file they're defined in are identified as having redundant internal accessibility. In this scenario, the declaration could be marked `private` or `fileprivate`. Reducing the visibility of declarations — encapsulation — helps with code maintainability and can improve compilation performance.

This analysis can be disabled with `--disable-redundant-internal-analysis`.

### Redundant Fileprivate Accessibility

Declarations that are marked `fileprivate` yet are not accessed from other types within the same file are identified as having redundant fileprivate accessibility. If a `fileprivate` declaration is only used within its own type, it should be marked `private` instead. Reducing the visibility of declarations helps with code maintainability and makes access boundaries clearer.

This analysis can be disabled with `--disable-redundant-fileprivate-analysis`.

### Unused Imports

Periphery can only detect unused imports of targets it has scanned. It cannot detect unused imports of other targets because the Swift source files are unavailable and uses of `@_exported` cannot be observed. `@_exported` is problematic because it changes the public interface of a target such that the declarations exported by the target are no longer necessarily declared by the imported target. For example, the `Foundation` target exports `Dispatch`, among other targets. If any given source file imports `Foundation` and references `DispatchQueue` but no other declarations from `Foundation`, then the `Foundation` import cannot be removed as it would also make the `DispatchQueue` type unavailable. To avoid false positives, therefore, Periphery only detects unused imports of targets it has scanned.
Expand Down
3 changes: 3 additions & 0 deletions Sources/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ swift_library(
"SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift",
"SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift",
"SourceGraph/Mutators/PubliclyAccessibleRetainer.swift",
"SourceGraph/Mutators/RedundantAccessibilityMarkerShared.swift",
"SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift",
"SourceGraph/Mutators/RedundantFilePrivateAccessibilityMarker.swift",
"SourceGraph/Mutators/RedundantInternalAccessibilityMarker.swift",
"SourceGraph/Mutators/RedundantProtocolMarker.swift",
"SourceGraph/Mutators/ResultBuilderRetainer.swift",
"SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift",
Expand Down
14 changes: 12 additions & 2 deletions Sources/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ public final class Configuration {
@Setting(key: "disable_redundant_public_analysis", defaultValue: false)
public var disableRedundantPublicAnalysis: Bool

@Setting(key: "disable_redundant_internal_analysis", defaultValue: false)
public var disableRedundantInternalAnalysis: Bool

@Setting(key: "disable_redundant_fileprivate_analysis", defaultValue: false)
public var disableRedundantFilePrivateAnalysis: Bool

@Setting(key: "show_nested_redundant_accessibility", defaultValue: false)
public var showNestedRedundantAccessibility: Bool

@Setting(key: "disable_unused_import_analysis", defaultValue: false)
public var disableUnusedImportAnalysis: Bool

Expand Down Expand Up @@ -224,10 +233,11 @@ public final class Configuration {

// MARK: - Private

lazy var settings: [any AbstractSetting] = [
private lazy var settings: [any AbstractSetting] = [
$project, $schemes, $excludeTargets, $excludeTests, $indexExclude, $reportExclude, $reportInclude, $outputFormat,
$retainPublic, $noRetainSPI, $retainFiles, $retainAssignOnlyProperties, $retainAssignOnlyPropertyTypes, $retainObjcAccessible,
$retainObjcAnnotated, $retainUnusedProtocolFuncParams, $retainSwiftUIPreviews, $disableRedundantPublicAnalysis,
$disableRedundantInternalAnalysis, $disableRedundantFilePrivateAnalysis, $showNestedRedundantAccessibility,
$disableUnusedImportAnalysis, $superfluousIgnoreComments, $retainUnusedImportedModules,
$externalEncodableProtocols, $externalCodableProtocols, $externalTestCaseClasses, $verbose, $quiet, $color,
$disableUpdateCheck, $strict, $indexStorePath,
Expand Down Expand Up @@ -256,7 +266,7 @@ public final class Configuration {
}
}

protocol AbstractSetting {
private protocol AbstractSetting {
associatedtype Value

var key: String { get }
Expand Down
Loading
Loading