Long Method (ARCH6180)
Esta página aún no está disponible en tu idioma.
Key ruby.quality.method-too-long · Severity info · Category quality
A method whose body exceeds the configured line threshold tends to do too many things, making it hard to read, test, and change.
Incorrect
Section titled “Incorrect”def process_order(order) validate(order) total = 0 order.items.each { |i| total += i.price * i.qty } apply_discount(order, total) charge_card(order) send_receipt(order) update_inventory(order) notify_warehouse(order) log_metrics(order)endCorrect
Section titled “Correct”def process_order(order) validate(order) total = calculate_total(order) charge(order, total) fulfill(order)endExtract small, well-named helper methods so each one carries a single responsibility.