Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

Flag redundant access levels same as enclosing context #1048

Closed

Description

@danwood

It would be great to flag code that is marked with an explicit access level (internal, private, fileprivate) that is redundant to the access level of the type that is enclosing that code.

I have already implemented this on a private branch - I'm just waiting to deal with #1042 before presenting this.

Not determined : Should this have its own flag? Or to avoid having too many new flags, could this feature be folded into an existing flag?

Here are some example of code that should be flagged. (The inner declarations, not the outer, and not the "(set)" specifiers)

private class Private {
    private var x: Int
}

fileprivate class FilePrivate {
    fileprivate var data: String = ""
    fileprivate func method() {}

    fileprivate struct Config {
        fileprivate var value: Int = 0
    }
}

internal class Internal {
    internal var count: Int = 0
}

fileprivate class SetterExample {
    fileprivate fileprivate(set) var redundantSetter: Int = 0
    fileprivate private(set) var redundantAccess: Int = 0
}

internal class InternalSetterExample {
    internal internal(set) var redundantBoth: Int = 0
    fileprivate fileprivate(set) var redundantSetter: Int = 0
    internal private(set) var redundantAccess: Int = 0
}

private class PrivateSetterExample {
    private private(set) var redundantBoth: Int = 0
}

Activity

  1. ileitch commented on Aug 12, 2026

    @ileitch
    Contributor

    This issue has been migrated to periphery-pro/issues#22 and is now tracked there.

    Periphery is moving to a commercial model, and issues are now handled in that repository. You can read about what's changing, and what it means for existing users, in A New Chapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions