anyobject_protocol - ApplebaumIan/BitbucketAPI GitHub Wiki

AnyObject Protocol

Prefer using AnyObject over class for class-only protocols.

  • Identifier: anyobject_protocol
  • Enabled by default: Disabled
  • Supports autocorrection: Yes
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 4.1.0
  • Default configuration: warning

Non Triggering Examples

protocol SomeProtocol {}

protocol SomeClassOnlyProtocol: AnyObject {}

protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {}

@objc protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {}

Triggering Examples

protocol SomeClassOnlyProtocol: ↓class {}

protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {}

@objc protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {}