Private Action
ID |
swift.private_action |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Swift |
Tags |
code-smell, encapsulation |
Description
Reports an @IBAction method that isn’t declared private or
fileprivate. Actions are wiring between the storyboard and the view
controller — external callers should not invoke them directly.
@IBAction func tapped(_ sender: UIButton) { ... } // FLAW
@IBAction private func tapped(_ sender: UIButton) { ... } // OK
Rationale
@IBAction methods are entry points wired up from Interface Builder,
not part of the controller’s API. Leaving them at the default
internal access exposes them to siblings in the same module, which
is rarely intentional and complicates refactoring (a rename or
signature change becomes a binary-API break for nothing).