Legacy Random

Prefer using type.random(in:) over legacy functions

  • Identifier: legacy_random
  • 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

Int.random(in: 0..<10)
Double.random(in: 8.6...111.34)
Float.random(in: 0 ..< 1)

Triggering Examples

arc4random()
arc4random_uniform(83)
drand48()