Is Disjoint

Prefer using Set.isDisjoint(with:) over Set.intersection(_:).isEmpty

  • Identifier: is_disjoint
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: idiomatic
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

_ = Set(syntaxKinds).isDisjoint(with: commentAndStringKindsSet)
let isObjc = !objcAttributes.isDisjoint(with: dictionary.enclosedSwiftAttributes)
_ = Set(syntaxKinds).intersection(commentAndStringKindsSet)
_ = !objcAttributes.intersection(dictionary.enclosedSwiftAttributes)

Triggering Examples

_ = Set(syntaxKinds).intersection(commentAndStringKindsSet).isEmpty
let isObjc = !objcAttributes.intersection(dictionary.enclosedSwiftAttributes).isEmpty