Repository navigation
Add new redundant_acl rule - #6941
Open
setouchi-h wants to merge 1 commit into
Open
setouchi-h wants to merge 1 commit into
setouchi-h wants to merge 1 commit into
Conversation
Generated by 🚫 Danger |
This branch has not been deployed
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.
Summary
Fixes #5828
Adds a new opt-in, correctable rule
redundant_aclthat flags access levelmodifiers which only restate the default access level:
internalon top-level declarations and on members ofinternaltypespublicin
public extension E { public func f() }Deliberately not flagged:
internalinside types more visible thaninternal, e.g.public struct S { internal let a = 1 }, as it documents an intentionalrestriction (matches the non-triggering example in the issue)
private, becauseprivateat file scope and inside a declaration havedifferent scopes, so it is never a pure restatement
private(set), which are covered byredundant_set_access_controlThe rule is added to
disabled_rulesin.swiftlint.ymlfor now. Enabling itand cleaning up the existing redundant
internalmodifiers in this repositorycan be done in a follow-up, as it was done for other rules.
Known limitation shared with
lower_acl_than_parent: correcting a modifierthat sits on its own line leaves an empty line behind, since the newline is
part of the next token's leading trivia.
If you'd rather have this as an option of
explicit_aclinstead of a separaterule, as suggested in the issue, I'm happy to rework it that way.
Test plan
are verified by the generated
RedundantACLRuleGeneratedTests.IntegrationTestspass, i.e. linting this repository with its ownconfiguration reports no violations.
internalmodifiers; applying
--fixremoves exactly those and the project stillbuilds.