Long Function (ARCH9180)
Ce contenu n’est pas encore disponible dans votre langue.
Key swift.quality.long-method · Severity info · Category quality
Flags functions longer than 50 lines.
Incorrect
Section titled “Incorrect”func process(_ order: Order) { // 80 lines of validation, pricing, persistence and notification}Correct
Section titled “Correct”func process(_ order: Order) throws { try validate(order) let priced = price(order) try persist(priced) notify(priced)}Extract cohesive steps into named functions.