discouraged_direct_init - ApplebaumIan/BitbucketAPI GitHub Wiki

Discouraged Direct Initialization

Discouraged direct initialization of types that can be harmful.

  • Identifier: discouraged_direct_init
  • Enabled by default: Enabled
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 3.0.0
  • Default configuration: warning, types: ["Bundle", "Bundle.init", "UIDevice", "UIDevice.init"]

Non Triggering Examples

let foo = UIDevice.current
let foo = Bundle.main
let foo = Bundle(path: "bar")
let foo = Bundle(identifier: "bar")
let foo = Bundle.init(path: "bar")
let foo = Bundle.init(identifier: "bar")

Triggering Examples

↓UIDevice()
↓Bundle()
let foo = ↓UIDevice()
let foo = ↓Bundle()
let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice())
↓UIDevice.init()
↓Bundle.init()
let foo = ↓UIDevice.init()
let foo = ↓Bundle.init()
let foo = bar(bundle: ↓Bundle.init(), device: ↓UIDevice.init())