Simple Fix for Long Lines

Christopher Vollick created

We had a few lines that were simply too long, so I broke them up.

Two of them I did by factoring out a parameter into a variable, which
felt a little weird, but I liked the overall flow of the line otherwise
and I didn't want to have the whole block need to change just because
the pattern was a few characters too long...

I think it's clear enough.

Change summary

lib/interac_email.rb                      | 7 ++++---
lib/redis_addresses.rb                    | 3 ++-
test/test_credit_card_customer_gateway.rb | 8 ++++++--
3 files changed, 12 insertions(+), 6 deletions(-)

Detailed changes

lib/interac_email.rb 🔗

@@ -141,8 +141,8 @@ class InteracEmail
 		end
 
 		def dkim_headers
-			# Apparently there can sometimes be multiple DKIM sigs
-			# And this library returns a scalar if there's one, or array otherwise
+			# Apparently there can sometimes be multiple DKIM sigs, and this
+			# library returns a scalar if there's one, or array otherwise.
 			# This Array method, when passed `nil` even returns an emtpy list!
 			Array(@m["DKIM-Signature"]).map { |s|
 				s.value
@@ -159,7 +159,8 @@ class InteracEmail
 
 			raise Error::NoDKIM, @m if dkim.empty?
 
-			raise Error::WrongDKIM, @m unless dkim.any? {|v| v[:d] == "payments.interac.ca" }
+			d = "payments.interac.ca"
+			raise Error::WrongDKIM, @m unless dkim.any? { |v| v[:d] == d }
 		end
 	end
 

lib/redis_addresses.rb 🔗

@@ -34,7 +34,8 @@ class RedisAddresses
 		# Basically it's "how long does each command take"
 		# The lower it is (default is 10), it will go back and forth
 		# to the client a ton
-		@redis.scan_each(match: "jmp_customer_#{@currency}_addresses-*", count: 1000) do |key|
+		pattern = "jmp_customer_#{@currency}_addresses-*"
+		@redis.scan_each(match: pattern, count: 1000) do |key|
 			@redis.smembers(key).each do |addr|
 				addrs[addr] << key
 			end

test/test_credit_card_customer_gateway.rb 🔗

@@ -8,11 +8,15 @@ CreditCardCustomerGateway::DB = Minitest::Mock.new
 
 class CreditCardCustomerGatewayTest < Minitest::Test
 	def setup
-		@gateway = CreditCardCustomerGateway.new("test@test.net", "0001", true, currency: "CAD")
+		@gateway = CreditCardCustomerGateway.new(
+			"test@test.net", "0001", true, currency: "CAD"
+		)
 	end
 
 	def test_no_cc_for_tombed
-		Customer::REDIS.expect(:get, "Tombed", ["jmp_customer_trust_level-0001"])
+		Customer::REDIS.expect(
+			:get, "Tombed", ["jmp_customer_trust_level-0001"]
+		)
 		assert_raises RuntimeError do
 			@gateway.sale("nonce", 1000)
 		end