Skip to content
New issue

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

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

Already on GitHub? # to your account

[Rule Request]: Private @IBAction opt-in rule #1931

Closed
ornithocoder opened this issue Nov 2, 2017 · 5 comments
Closed

[Rule Request]: Private @IBAction opt-in rule #1931

ornithocoder opened this issue Nov 2, 2017 · 5 comments
Labels
rule-request Requests for a new rules.

Comments

@ornithocoder
Copy link
Contributor

ornithocoder commented Nov 2, 2017

This is a request to introduce a new opt-in rule which warns against public IBActions.

Triggering example:

@IBAction func fooButtonTapped(_ sender: UIButton) {
    // ...
}

Non-triggering example:

@IBAction private func fooSegmentedControlChanged(_ sender: UISegmentedControl) {
    // ...
}
private extension Toto {
    @IBAction func fooSegmentedControlChanged(_ sender: UISegmentedControl) {
        // ...
    }
}

Workaround via custom rule (snippet from .swiftlint.yml) while the rule isn't implemented/merged into master:

custom_rules:
  private_ibaction:
    name: "Private @IBAction"
    regex: "@IBAction\\s+func"
    message: "@IBAction should be private"
    severity: warning
@marcelofabri marcelofabri added the rule-request Requests for a new rules. label Nov 2, 2017
@ornithocoder
Copy link
Contributor Author

ornithocoder commented Nov 2, 2017

@marcelofabri @jpsim let me know if this makes sense to you. In case it does, I'll work on it.

In my project we keep all our @IBActions private, and we test the code by sending actions (.sendActions(_:)) to the controllers (touch up inside, value changed, etc...).

@marcelofabri
Copy link
Collaborator

I think this would be a nice rule 👍

@jpsim
Copy link
Collaborator

jpsim commented Nov 2, 2017

Sounds reasonable as opt-in.

@ornithocoder
Copy link
Contributor Author

Super. I'll work on it tomorrow morning :-) Thanks guys!

ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Nov 7, 2017
ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Nov 7, 2017
ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Nov 7, 2017
ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Nov 11, 2017
ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Nov 17, 2017
@marcelofabri
Copy link
Collaborator

Implemented in #1935.

dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Dec 18, 2017
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Dec 18, 2017
Moves entry to new section. (+1 squashed commit)
Squashed commits:
[97ce04a] Adds new opt-in rule, private_action

Implements realm#1931.
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Dec 18, 2017
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Dec 18, 2017
Implements realm#1931. (+1 squashed commit)
Squashed commits:
[5911dcc] Fix false positives in control_statement when methods with keyword names are used

Fixes realm#1946 (+1 squashed commit)
Squashed commits:
[4cdcc48] Updates changelog entry
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Dec 18, 2017
Moves entry to new section. (+1 squashed commit)
Squashed commits:
[97ce04a] Adds new opt-in rule, private_action

Implements realm#1931.
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Dec 18, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

3 participants