From a7e89e5f3859c4beecb170a3a387aa6774e3497b Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Tue, 27 May 2025 12:05:58 -0400 Subject: [PATCH] Fix Whitespace Based Lint Errors This is a combination of strings not lining up, "when" statements that were indented, extra blank lines, missing blank lines, etc. --- bin/check_electrum_wallet_completeness | 4 ++-- bin/correct_duplicate_addrs | 6 +++--- bin/process_pending_btc_transactions | 16 ++++++++-------- bin/reassert_electrum_notification | 4 ++-- lib/interac_email.rb | 6 ++++-- test/test_helper.rb | 1 - 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/bin/check_electrum_wallet_completeness b/bin/check_electrum_wallet_completeness index 880fc562d8f90c07ea7a5943b14f6bf8cc38320d..44badf2252b0b119b958e80db970f53f84fc365d 100755 --- a/bin/check_electrum_wallet_completeness +++ b/bin/check_electrum_wallet_completeness @@ -19,7 +19,7 @@ electrum_addrs = electrum.listaddresses addrs = RedisAddresses.new(redis, config[:currency]) addrs.get_addresses_with_users.each do |addr, keys| unless electrum_addrs.include?(addr) - puts "The address #{addr} (included in #{keys.join(', ')}) "\ - "isn't included in electrum's list" + puts "The address #{addr} (included in #{keys.join(', ')}) " \ + "isn't included in electrum's list" end end diff --git a/bin/correct_duplicate_addrs b/bin/correct_duplicate_addrs index 12e80a1425a47ede1c197be19a7f961ee5c004d6..e71a4789daa140388fc0ded4f0f8fe9519a2ea86 100755 --- a/bin/correct_duplicate_addrs +++ b/bin/correct_duplicate_addrs @@ -13,9 +13,9 @@ redis = Redis.new customer_id = ENV["DEFAULT_CUSTOMER_ID"] unless customer_id puts "The env-var DEFAULT_CUSTOMER_ID must be set to the ID " \ - "of the customer who will receive the duplicated addrs, preferably " \ - "a support customer or something linked to notifications when " \ - "stray money is sent to these addresses" + "of the customer who will receive the duplicated addrs, preferably " \ + "a support customer or something linked to notifications when " \ + "stray money is sent to these addresses" exit 1 end diff --git a/bin/process_pending_btc_transactions b/bin/process_pending_btc_transactions index f8483e7d7924a79a92130a1f89ccaf179b97cd99..b5bd6fd3dda65ef57efd2dce2c0f0b9f095c0478 100755 --- a/bin/process_pending_btc_transactions +++ b/bin/process_pending_btc_transactions @@ -57,14 +57,14 @@ canadianbitcoins = Nokogiri::HTML.parse( ) case CONFIG[:electrum][:currency] - when "btc" - exchange_row = canadianbitcoins.at("#ticker > table > tbody > tr") - raise "Bitcoin row has moved" unless exchange_row.at("td").text == "Bitcoin" - when "bch" - exchange_row = canadianbitcoins.at("#ticker > table > tbody > tr:nth-child(2)") - raise "Bitcoin Cash row has moved" unless exchange_row.at("td").text == "Bitcoin Cash" - else - raise "Unknown currency #{CONFIG[:electrum][:currency]}" +when "btc" + exchange_row = canadianbitcoins.at("#ticker > table > tbody > tr") + raise "Bitcoin row has moved" unless exchange_row.at("td").text == "Bitcoin" +when "bch" + exchange_row = canadianbitcoins.at("#ticker > table > tbody > tr:nth-child(2)") + raise "Bitcoin Cash row has moved" unless exchange_row.at("td").text == "Bitcoin Cash" +else + raise "Unknown currency #{CONFIG[:electrum][:currency]}" end sell_price = {} diff --git a/bin/reassert_electrum_notification b/bin/reassert_electrum_notification index 1dc68923b7ad4b5dfa6234605e5bcd6317d8f666..181c01f25289988e6fa53bd94d34c1b505a0ee63 100755 --- a/bin/reassert_electrum_notification +++ b/bin/reassert_electrum_notification @@ -24,8 +24,8 @@ addrs.get_addresses_with_users(redis).each do |addr, keys| customer_id = match[1] url = "https://pay.jmp.chat/electrum_notify?" \ - "address=#{addr}&customer_id=#{customer_id}" \ - "¤cy=#{config[:currency]}" + "address=#{addr}&customer_id=#{customer_id}" \ + "¤cy=#{config[:currency]}" unless electrum.notify(addr, url) puts "Failed to setup #{addr} to notify #{url}. Skipping" diff --git a/lib/interac_email.rb b/lib/interac_email.rb index ade6e38a770e5b61637fb88ffa0f586d6b3400db..a25804d52f677ce11b457b5e828c9e48f27dd13a 100644 --- a/lib/interac_email.rb +++ b/lib/interac_email.rb @@ -143,7 +143,7 @@ class InteracEmail def dkim_headers # Apparently there can sometimes be multiple DKIM sigs # And this library returns a scalar if there's one, or array otherwise - [@m["DKIM-Signature"]].flatten.compact.map {|h| + [@m["DKIM-Signature"]].flatten.compact.map { |h| h.value &.split(/;\s*/) &.each_with_object({}) { |f, h| @@ -157,6 +157,7 @@ class InteracEmail dkim = dkim_headers raise Error::DKIM, @m if dkim.empty? + raise Error::WrongDKIM, @m unless dkim.any? {|v| v[:d] == "payments.interac.ca" } end end @@ -202,6 +203,7 @@ class InteracEmail # other fields I'd be more worried about ms = paragraphs.select { |p| p.start_with?("Message:") } raise Error::NoMessage, self if ms.empty? + ms.first.sub(/^Message:\s*/, "") end @@ -314,7 +316,7 @@ class InteracEmail end def to_s - "A manual E-Transfer has been received from \"%s\" for "\ + "A manual E-Transfer has been received from \"%s\" for " \ "$%0.2f. Message: %s\nTo deposit go to %s" % [ sender_name, dollars, diff --git a/test/test_helper.rb b/test/test_helper.rb index 9850c4bca361c411fab0bb1763fc5d44cac34dae..504a906dc6aed85402847871847ac7a83a044b09 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,7 +9,6 @@ require "minitest/autorun" ## still uses the old casing MiniTest = Minitest unless defined?(MiniTest) - require "rantly/minitest_extensions" require "webmock/minitest" begin