From f74a99d6ef6e7608df74e099738cd569976fa555 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Tue, 27 May 2025 12:06:05 -0400 Subject: [PATCH] Simple Fix for Long Lines 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. --- 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(-) diff --git a/lib/interac_email.rb b/lib/interac_email.rb index c19959cc65295ddc6c6d857c62551b886ac84caf..7b634d11004a110e740b7b69df46c21f31cb3c4a 100644 --- a/lib/interac_email.rb +++ b/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 diff --git a/lib/redis_addresses.rb b/lib/redis_addresses.rb index 8a24658f911cf47da38e59a97e9375d2555f770b..0ea91fa035c0af231e8151105c0cff2496b0210a 100644 --- a/lib/redis_addresses.rb +++ b/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 diff --git a/test/test_credit_card_customer_gateway.rb b/test/test_credit_card_customer_gateway.rb index 28cf4e873c358cfe05ecde8cb8be8d88f3055f35..c87da5b458874f3ec75afc9370b1f88e9040c05f 100644 --- a/test/test_credit_card_customer_gateway.rb +++ b/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