style(rubocop): Style/IdenticalConditionalBranches

This commit is contained in:
Adam Cooke
2024-02-12 09:40:31 +00:00
parent 6ad56ee9c9
commit 6a58ecf605
3 changed files with 9 additions and 15 deletions
+1 -5
View File
@@ -48,11 +48,7 @@ class ApplicationController < ActionController::Base
helper_method :page_title helper_method :page_title
def redirect_to_with_return_to(url, *args) def redirect_to_with_return_to(url, *args)
if params[:return_to].blank? || !params[:return_to].starts_with?("/") redirect_to url_with_return_to(url), *args
redirect_to url_with_return_to(url), *args
else
redirect_to url_with_return_to(url), *args
end
end end
def set_timezone def set_timezone
+6 -6
View File
@@ -159,13 +159,11 @@ module Postal
# The client is not negotiating a TLS handshake at this time # The client is not negotiating a TLS handshake at this time
begin begin
# Read 10kiB of data at a time from the socket. # Read 10kiB of data at a time from the socket.
buffers[io] << io.readpartial(10_240)
# There is an extra step for SSL sockets # There is an extra step for SSL sockets
case io if io.is_a?(OpenSSL::SSL::SSLSocket)
when OpenSSL::SSL::SSLSocket
buffers[io] << io.readpartial(10_240)
buffers[io] << io.readpartial(10_240) while io.pending.positive? buffers[io] << io.readpartial(10_240) while io.pending.positive?
else
buffers[io] << io.readpartial(10_240)
end end
rescue EOFError, Errno::ECONNRESET, Errno::ETIMEDOUT rescue EOFError, Errno::ECONNRESET, Errno::ETIMEDOUT
# Client went away # Client went away
@@ -280,12 +278,14 @@ module Postal
end end
# If we have been spawned to replace an existing processm shut down the # If we have been spawned to replace an existing processm shut down the
# parent after listening. # parent after listening.
# rubocop:disable Style/IdenticalConditionalBranches
if ENV["SERVER_FD"] if ENV["SERVER_FD"]
listen listen
kill_parent kill_parent if ENV["SERVER_FD"]
else else
listen listen
end end
# rubocop:enable Style/IdenticalConditionalBranches
run_event_loop run_event_loop
end end
+2 -4
View File
@@ -18,18 +18,16 @@ module Postal
user.password = cli.ask("Initial Password".ljust(20, " ") + ": ") { |value| value.echo = "*" } user.password = cli.ask("Initial Password".ljust(20, " ") + ": ") { |value| value.echo = "*" }
block.call(user) if block_given? block.call(user) if block_given?
puts
if user.save if user.save
puts
puts "User has been created with e-mail address \e[32m#{user.email_address}\e[0m" puts "User has been created with e-mail address \e[32m#{user.email_address}\e[0m"
puts
else else
puts
puts "\e[31mFailed to create user\e[0m" puts "\e[31mFailed to create user\e[0m"
for error in user.errors.full_messages for error in user.errors.full_messages
puts " * #{error}" puts " * #{error}"
end end
puts
end end
puts
end end
end end