Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule to omit internal keyword from declarations with internal access control #233

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

calda
Copy link
Member

@calda calda commented Aug 1, 2023

Summary

This PR proposes a new rule to omit the internal keyword from declarations with internal access control.

Autocorrect is implemented in the new redundantInternal SwiftFormat rule, which was added in nicklockwood/SwiftFormat#1486.

// WRONG
internal class Spaceship {
  internal init() {  }

  internal func travel(to planet: Planet) {  }
}

// RIGHT, because internal access control is implied if no other access control level is specified.
class Spaceship {
  init() {  }

  func travel(to planet: Planet) {  }
}

Reasoning

Internal access control is implied for declarations without an explicit access control level, so the internal keyword is redundant.

Please react with 👍/👎 if you agree or disagree with this proposal.

README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@bachand bachand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

README.md Outdated Show resolved Hide resolved
calda and others added 2 commits August 4, 2023 08:20
Co-authored-by: Michael Bachand <michael.bachand@airbnb.com>
@calda calda merged commit 741e55b into master Aug 8, 2023
3 checks passed
@calda calda deleted the cal--redundantInternal branch August 8, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants