From e968e39064eaf3d437e184db37dda6fe89f9a991 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 28 Jun 2016 09:49:18 -0700 Subject: [PATCH] quick refactor to make a future pull request more focused We can use `reduce` here to easily get the result of applying the transformations without overwriting the original `email` variable. --- .rubocop.yml | 3 +++ lib/email_repair/mechanic.rb | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9ee1c59..606a04c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,9 @@ TrailingComma: AccessModifierIndentation: EnforcedStyle: outdent +SingleLineBlockParams: + Enabled: false + MethodLength: Max: 15 diff --git a/lib/email_repair/mechanic.rb b/lib/email_repair/mechanic.rb index f4aecd1..62d80c1 100644 --- a/lib/email_repair/mechanic.rb +++ b/lib/email_repair/mechanic.rb @@ -34,9 +34,7 @@ def repair_all(emails) def repair(email) return unless email - repairs.each { |repair| email = repair.repair(email) } - - email + repairs.reduce(email) { |memo, repair| repair.repair(memo) } end class CommonMistakeRepair