diff --git a/.rubocop.yml b/.rubocop.yml index 17ab0f23..59d78f88 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -125,6 +125,9 @@ Style/MultilineBlockChain: Exclude: - "spec/**/*.rb" +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: consistent_comma + Metrics/AbcSize: Enabled: false diff --git a/app/controllers/servers_controller.rb b/app/controllers/servers_controller.rb index c5b40ee5..f0de090e 100644 --- a/app/controllers/servers_controller.rb +++ b/app/controllers/servers_controller.rb @@ -45,8 +45,16 @@ def update extra_params = [:spam_threshold, :spam_failure_threshold, :postmaster_address] if current_user.admin? - extra_params += [:send_limit, :allow_sender, :privacy_mode, :log_smtp_data, :outbound_spam_threshold, - :message_retention_days, :raw_message_retention_days, :raw_message_retention_size] + extra_params += [ + :send_limit, + :allow_sender, + :privacy_mode, + :log_smtp_data, + :outbound_spam_threshold, + :message_retention_days, + :raw_message_retention_days, + :raw_message_retention_size, + ] end if @server.update(safe_params(*extra_params)) diff --git a/app/lib/dns_resolver.rb b/app/lib/dns_resolver.rb index 1f7189a4..57b8aa1d 100644 --- a/app/lib/dns_resolver.rb +++ b/app/lib/dns_resolver.rb @@ -111,9 +111,11 @@ def ip_to_hostname(ip_address, **options) def dns(raise_timeout_errors: false) Resolv::DNS.open(nameserver: @nameservers, raise_timeout_errors: raise_timeout_errors) do |dns| - dns.timeouts = [Postal::Config.dns.timeout, - Postal::Config.dns.timeout / 2, - Postal::Config.dns.timeout / 2] + dns.timeouts = [ + Postal::Config.dns.timeout, + Postal::Config.dns.timeout / 2, + Postal::Config.dns.timeout / 2, + ] yield dns end end diff --git a/app/lib/reply_separator.rb b/app/lib/reply_separator.rb index b5167ed6..17b18d54 100644 --- a/app/lib/reply_separator.rb +++ b/app/lib/reply_separator.rb @@ -13,7 +13,7 @@ class ReplySeparator /^>*\s*On.{10,200}wrote:\s*$.*/m, /^>*\s*Sent from my.*/m, /^>*\s*=== Please reply above this line ===.*/m, - /(^>.*\n?){10,}/ + /(^>.*\n?){10,}/, ].freeze def self.separate(text) diff --git a/app/lib/smtp_server/client.rb b/app/lib/smtp_server/client.rb index 51619156..bb6d03a9 100644 --- a/app/lib/smtp_server/client.rb +++ b/app/lib/smtp_server/client.rb @@ -155,7 +155,7 @@ def ehlo(data) [ "250-My capabilities are", Postal::Config.smtp_server.tls_enabled? && !@tls ? "250-STARTTLS" : nil, - "250 AUTH CRAM-MD5 PLAIN LOGIN" + "250 AUTH CRAM-MD5 PLAIN LOGIN", ].compact end diff --git a/app/lib/worker/process.rb b/app/lib/worker/process.rb index 5a5d0a34..181d49d0 100644 --- a/app/lib/worker/process.rb +++ b/app/lib/worker/process.rb @@ -26,7 +26,7 @@ class Process # @return [Array] JOBS = [ Jobs::ProcessQueuedMessagesJob, - Jobs::ProcessWebhookRequestsJob + Jobs::ProcessWebhookRequestsJob, ].freeze # An array of tasks that should be processed @@ -41,7 +41,7 @@ class Process PruneSuppressionListsScheduledTask, PruneWebhookRequestsScheduledTask, SendNotificationsScheduledTask, - TidyQueuedMessagesTask + TidyQueuedMessagesTask, ].freeze # @param [Integer] thread_count The number of worker threads to run in this process diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index ca55f952..615869a8 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -6,5 +6,5 @@ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported # notations and behaviors. Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, ] diff --git a/spec/lib/dns_resolver_spec.rb b/spec/lib/dns_resolver_spec.rb index ae09b888..b95b3bb0 100644 --- a/spec/lib/dns_resolver_spec.rb +++ b/spec/lib/dns_resolver_spec.rb @@ -66,7 +66,7 @@ it "returns a list of TXT records" do expect(resolver.txt("dnstest.postalserver.io").sort).to eq [ "an example txt record", - "another example" + "another example", ] end @@ -79,7 +79,7 @@ it "returns a list of TXT records" do expect(resolver.txt("dnstest.postalserver.io", raise_timeout_errors: true).sort).to eq [ "an example txt record", - "another example" + "another example", ] end @@ -120,7 +120,7 @@ it "returns a list of MX records" do expect(resolver.mx("dnstest.postalserver.io")).to eq [ [10, "mx1.dnstest.postalserver.io"], - [20, "mx2.dnstest.postalserver.io"] + [20, "mx2.dnstest.postalserver.io"], ] end @@ -133,7 +133,7 @@ it "returns a list of MX records" do expect(resolver.mx("dnstest.postalserver.io", raise_timeout_errors: true)).to eq [ [10, "mx1.dnstest.postalserver.io"], - [20, "mx2.dnstest.postalserver.io"] + [20, "mx2.dnstest.postalserver.io"], ] end @@ -150,7 +150,7 @@ it "returns the nameserver names that are authoritative for the given domain" do expect(resolver.effective_ns("postalserver.io").sort).to eq [ "prestigious-honeybadger.katapultdns.com", - "the-cake-is-a-lie.katapultdns.com" + "the-cake-is-a-lie.katapultdns.com", ] end @@ -163,7 +163,7 @@ it "returns a list of NS records" do expect(resolver.effective_ns("postalserver.io", raise_timeout_errors: true).sort).to eq [ "prestigious-honeybadger.katapultdns.com", - "the-cake-is-a-lie.katapultdns.com" + "the-cake-is-a-lie.katapultdns.com", ] end diff --git a/spec/lib/postal/legacy_config_source_spec.rb b/spec/lib/postal/legacy_config_source_spec.rb index 0032a3ba..e9d9f678 100644 --- a/spec/lib/postal/legacy_config_source_spec.rb +++ b/spec/lib/postal/legacy_config_source_spec.rb @@ -73,7 +73,7 @@ module Postal it "returns a value for postal.smtp_relays" do expect(config.postal.smtp_relays).to eq [ { "host" => "1.2.3.4", "port" => 25, "ssl_mode" => "Auto" }, - { "host" => "2.2.2.2", "port" => 2525, "ssl_mode" => "None" } + { "host" => "2.2.2.2", "port" => 2525, "ssl_mode" => "None" }, ] end end diff --git a/spec/lib/smtp_client/server_spec.rb b/spec/lib/smtp_client/server_spec.rb index 20e4ff10..0f3ac1ba 100644 --- a/spec/lib/smtp_client/server_spec.rb +++ b/spec/lib/smtp_client/server_spec.rb @@ -29,7 +29,7 @@ module SMTPClient have_attributes(ip_address: "2a00::67a0:a::1234"), have_attributes(ip_address: "2a00::67a0:a::2345"), have_attributes(ip_address: "1.2.3.4"), - have_attributes(ip_address: "2.3.4.5") + have_attributes(ip_address: "2.3.4.5"), ] end end @@ -43,7 +43,7 @@ module SMTPClient it "returns ipv4 endpoints" do expect(server.endpoints).to match [ have_attributes(ip_address: "1.2.3.4"), - have_attributes(ip_address: "2.3.4.5") + have_attributes(ip_address: "2.3.4.5"), ] end end @@ -57,7 +57,7 @@ module SMTPClient it "returns ipv6 endpoints" do expect(server.endpoints).to match [ have_attributes(ip_address: "2a00::67a0:a::1234"), - have_attributes(ip_address: "2a00::67a0:a::2345") + have_attributes(ip_address: "2a00::67a0:a::2345"), ] end end diff --git a/spec/lib/smtp_server/client/helo_spec.rb b/spec/lib/smtp_server/client/helo_spec.rb index 8b6fb679..7c1e51f1 100644 --- a/spec/lib/smtp_server/client/helo_spec.rb +++ b/spec/lib/smtp_server/client/helo_spec.rb @@ -19,7 +19,7 @@ module SMTPServer describe "EHLO" do it "returns the capabilities" do expect(client.handle("EHLO test.example.com")).to eq ["250-My capabilities are", - "250 AUTH CRAM-MD5 PLAIN LOGIN"] + "250 AUTH CRAM-MD5 PLAIN LOGIN",] end context "when TLS is enabled" do @@ -27,7 +27,7 @@ module SMTPServer allow(Postal::Config.smtp_server).to receive(:tls_enabled?).and_return(true) expect(client.handle("EHLO test.example.com")).to eq ["250-My capabilities are", "250-STARTTLS", - "250 AUTH CRAM-MD5 PLAIN LOGIN"] + "250 AUTH CRAM-MD5 PLAIN LOGIN",] end end end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index a3689fb4..70dae6f4 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -209,7 +209,7 @@ "postmaster@example.com", "admin@example.com", "administrator@example.com", - "hostmaster@example.com" + "hostmaster@example.com", ] end end diff --git a/spec/senders/smtp_sender_spec.rb b/spec/senders/smtp_sender_spec.rb index d61c532d..4d44e306 100644 --- a/spec/senders/smtp_sender_spec.rb +++ b/spec/senders/smtp_sender_spec.rb @@ -180,8 +180,10 @@ it "includes both endpoints in the array of endpoints tried" do sender.start - expect(sender.endpoints).to match([have_attributes(ip_address: "1.2.3.4"), - have_attributes(ip_address: "2.3.4.5")]) + expect(sender.endpoints).to match([ + have_attributes(ip_address: "1.2.3.4"), + have_attributes(ip_address: "2.3.4.5"), + ]) end end