green-code-initiative / ecoCode

Reduce the environmental footprint of your software programs with SonarQube
https://ecocode.io
GNU General Public License v3.0
139 stars 76 forks source link

[EC528] Swift port #313

Open zippy1978 opened 3 months ago

zippy1978 commented 3 months ago

Shaking or vibrating an iOS device is possible using UIFeedbackGenerator. Behind this effect stands a specific hardware component, the Taptic Engine, which consumes power. As a consequence, its usage should be carefully considered, especially if its added value is not clear.

Noncompliant Code Example

import UIKit

func triggerVibration() {
    let generator = UIImpactFeedbackGenerator(style: .heavy)
    generator.impactOccurred()
}