Skip to content

Commit

Permalink
style(rubocop): Style/TrailingCommaInArrayLiteral
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Mar 12, 2024
1 parent d84152e commit 4e13577
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ Style/MultilineBlockChain:
Exclude:
- "spec/**/*.rb"

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma

Metrics/AbcSize:
Enabled: false

Expand Down
12 changes: 10 additions & 2 deletions app/controllers/servers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 5 additions & 3 deletions app/lib/dns_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/reply_separator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/smtp_server/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/lib/worker/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Process
# @return [Array<Class>]
JOBS = [
Jobs::ProcessQueuedMessagesJob,
Jobs::ProcessWebhookRequestsJob
Jobs::ProcessWebhookRequestsJob,
].freeze

# An array of tasks that should be processed
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
12 changes: 6 additions & 6 deletions spec/lib/dns_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/postal/legacy_config_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/smtp_client/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/smtp_server/client/helo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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
it "returns capabilities include starttls" do
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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/domain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
"[email protected]",
]
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/senders/smtp_sender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4e13577

Please sign in to comment.