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

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

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

Comments

Projects
None yet
3 participants
@ornithocoder
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
@ornithocoder

This comment has been minimized.

Show comment
Hide comment
@ornithocoder

ornithocoder Nov 2, 2017

Contributor

@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...).

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Nov 2, 2017

Collaborator

I think this would be a nice rule 👍

Collaborator

marcelofabri commented Nov 2, 2017

I think this would be a nice rule 👍

@jpsim

This comment has been minimized.

Show comment
Hide comment
@jpsim

jpsim Nov 2, 2017

Collaborator

Sounds reasonable as opt-in.

Collaborator

jpsim commented Nov 2, 2017

Sounds reasonable as opt-in.

@ornithocoder

This comment has been minimized.

Show comment
Hide comment
@ornithocoder

ornithocoder Nov 2, 2017

Contributor

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

Contributor

ornithocoder commented Nov 2, 2017

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

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Dec 5, 2017

Collaborator

Implemented in #1935.

Collaborator

marcelofabri commented Dec 5, 2017

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

Updates changelog entry
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

Adds new opt-in rule, private_action
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

Updates changelog entry
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

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