summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakuya Noguchi <takninnovationresearch@gmail.com>2020-11-05 12:49:30 +0000
committerTakuya Noguchi <takninnovationresearch@gmail.com>2020-11-05 13:22:39 +0000
commitdcb12d57fab8fa43ccd1d252bc749081af142d06 (patch)
treefe90d9b1e1246c5903e953f93f8935bdccaa27a9
parent2dfa78cc38e8e4220369a7e6c3ff1995cdc3276f (diff)
downloadgitlab-shell-dcb12d57fab8fa43ccd1d252bc749081af142d06.tar.gz
Update rubocop from 0.49.1 to 1.2.0update-rubocop-from-0.49.1-to-1.2.0
https://github.com/rubocop-hq/rubocop/blob/v1.2.0/CHANGELOG.md Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
-rw-r--r--.rubocop.yml42
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock35
-rwxr-xr-xbin/install4
-rw-r--r--spec/gitlab_shell_authorized_keys_check_spec.rb10
-rw-r--r--spec/gitlab_shell_authorized_principals_check_spec.rb2
-rw-r--r--spec/gitlab_shell_custom_git_receive_pack_spec.rb18
-rw-r--r--spec/gitlab_shell_custom_git_upload_pack_spec.rb18
-rw-r--r--spec/gitlab_shell_discover_spec.rb6
-rw-r--r--spec/gitlab_shell_lfs_authentication_spec.rb14
-rw-r--r--spec/gitlab_shell_personal_access_token_spec.rb26
-rw-r--r--spec/gitlab_shell_two_factor_recovery_spec.rb6
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/gitlab_shell_setup.rb7
-rw-r--r--spec/support/http_unix_server.rb16
15 files changed, 107 insertions, 101 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 0c080ae..ef28aad 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,21 +1,36 @@
# Exclude some of GitLab files
AllCops:
- TargetRubyVersion: 2.3
- Exclude:
- - 'spec/**/*'
- - 'vendor/**/*'
- - 'tmp/**/*'
- - 'bin/**/*'
- - 'hooks/**/*'
- - 'Guardfile'
+ TargetRubyVersion: 2.7
+ NewCops: enable
+
+Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
+ Enabled: true
+Lint/EmptyBlock: # (new in 1.1)
+ Enabled: true
+Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
+ Enabled: true
+Lint/ToEnumArguments: # (new in 1.1)
+ Enabled: true
+Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
+ Enabled: true
+Style/ArgumentsForwarding: # (new in 1.1)
+ Enabled: true
+Style/CollectionCompact: # (new in 1.2)
+ Enabled: true
+Style/DocumentDynamicEvalDefinition: # (new in 1.1)
+ Enabled: true
+Style/NegatedIfElseCondition: # (new in 1.2)
+ Enabled: true
+Style/SwapValues: # (new in 1.1)
+ Enabled: true
Layout/DotPosition:
Enabled: false
-Lint/AmbiguousBlockAssociation:
+Layout/LineLength:
Enabled: false
-Metrics/LineLength:
+Lint/AmbiguousBlockAssociation:
Enabled: false
Metrics/MethodLength:
@@ -36,10 +51,10 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Enabled: false
-Style/Documentation:
+Naming/AccessorMethodName:
Enabled: false
-Style/StringLiterals:
+Style/Documentation:
Enabled: false
Style/StringLiterals:
@@ -48,9 +63,6 @@ Style/StringLiterals:
Style/GlobalVars:
Enabled: false
-Style/AccessorMethodName:
- Enabled: false
-
Style/GuardClause:
Enabled: false
diff --git a/Gemfile b/Gemfile
index 7a9efc1..04d5c99 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,5 +2,5 @@ source 'https://rubygems.org'
group :development, :test do
gem 'rspec', '~> 3.8.0'
- gem 'rubocop', '0.49.1', require: false
+ gem 'rubocop', '~> 1.2', require: false
end
diff --git a/Gemfile.lock b/Gemfile.lock
index cddfc93..81261cc 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,15 +1,14 @@
GEM
remote: https://rubygems.org/
specs:
- ast (2.4.0)
+ ast (2.4.1)
diff-lcs (1.3)
- parallel (1.12.1)
- parser (2.5.1.2)
- ast (~> 2.4.0)
- powerpack (0.1.2)
- rainbow (2.2.2)
- rake
- rake (12.3.3)
+ parallel (1.19.2)
+ parser (2.7.2.0)
+ ast (~> 2.4.1)
+ rainbow (3.0.0)
+ regexp_parser (1.8.2)
+ rexml (3.2.4)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
@@ -23,22 +22,26 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
- rubocop (0.49.1)
+ rubocop (1.2.0)
parallel (~> 1.10)
- parser (>= 2.3.3.1, < 3.0)
- powerpack (~> 0.1)
- rainbow (>= 1.99.1, < 3.0)
+ parser (>= 2.7.1.5)
+ rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 1.8)
+ rexml
+ rubocop-ast (>= 1.0.1)
ruby-progressbar (~> 1.7)
- unicode-display_width (~> 1.0, >= 1.0.1)
- ruby-progressbar (1.9.0)
- unicode-display_width (1.4.0)
+ unicode-display_width (>= 1.4.0, < 2.0)
+ rubocop-ast (1.1.1)
+ parser (>= 2.7.1.5)
+ ruby-progressbar (1.10.1)
+ unicode-display_width (1.7.0)
PLATFORMS
ruby
DEPENDENCIES
rspec (~> 3.8.0)
- rubocop (= 0.49.1)
+ rubocop (~> 1.2)
BUNDLED WITH
2.1.4
diff --git a/bin/install b/bin/install
index 323e758..f20fecf 100755
--- a/bin/install
+++ b/bin/install
@@ -4,12 +4,12 @@
require_relative '../support/gitlab_config'
config = GitlabConfig.new
-key_dir = File.dirname("#{config.auth_file}")
+key_dir = File.dirname(config.auth_file.to_s)
repository_storage_paths = ARGV
commands = [
%W(mkdir -p #{key_dir}),
- %W(chmod 700 #{key_dir}),
+ %W(chmod 700 #{key_dir})
]
repository_storage_paths.each do |repository_storage_path|
diff --git a/spec/gitlab_shell_authorized_keys_check_spec.rb b/spec/gitlab_shell_authorized_keys_check_spec.rb
index 91b874d..fdc547e 100644
--- a/spec/gitlab_shell_authorized_keys_check_spec.rb
+++ b/spec/gitlab_shell_authorized_keys_check_spec.rb
@@ -38,15 +38,15 @@ describe 'bin/gitlab-shell-authorized-keys-check' do
expect(status).to be_success
end
- it' fails when not enough arguments are given' do
+ it ' fails when not enough arguments are given' do
output, status = run!(key: nil)
expect(output).to eq('')
expect(status).not_to be_success
end
- it' fails when too many arguments are given' do
- output, status = run!(key: ['a', 'b'])
+ it ' fails when too many arguments are given' do
+ output, status = run!(key: %w[a b])
expect(output).to eq('')
expect(status).not_to be_success
@@ -70,7 +70,7 @@ describe 'bin/gitlab-shell-authorized-keys-check' do
describe 'without go features' do
before(:all) do
write_config(
- "gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}",
+ "gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}"
)
end
@@ -80,7 +80,7 @@ describe 'bin/gitlab-shell-authorized-keys-check' do
describe 'without go features (via go)', :go do
before(:all) do
write_config(
- "gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}",
+ "gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}"
)
end
diff --git a/spec/gitlab_shell_authorized_principals_check_spec.rb b/spec/gitlab_shell_authorized_principals_check_spec.rb
index 14693ab..c7d8a4e 100644
--- a/spec/gitlab_shell_authorized_principals_check_spec.rb
+++ b/spec/gitlab_shell_authorized_principals_check_spec.rb
@@ -47,7 +47,7 @@ describe 'bin/gitlab-shell-authorized-principals-check' do
cmd = [
authorized_principals_check_path,
key_id,
- principals,
+ principals
].flatten.compact
output = IO.popen(cmd, &:read)
diff --git a/spec/gitlab_shell_custom_git_receive_pack_spec.rb b/spec/gitlab_shell_custom_git_receive_pack_spec.rb
index 1979738..cfc5a0a 100644
--- a/spec/gitlab_shell_custom_git_receive_pack_spec.rb
+++ b/spec/gitlab_shell_custom_git_receive_pack_spec.rb
@@ -7,7 +7,7 @@ require 'base64'
describe 'Custom bin/gitlab-shell git-receive-pack' do
include_context 'gitlab shell'
- let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-receive-pack group/repo' } }
+ let(:env) { { 'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-receive-pack group/repo' } }
let(:divider) { "remote: ========================================================================\n" }
before(:context) do
@@ -15,11 +15,11 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
end
def mock_server(server)
- server.mount_proc('/geo/proxy_git_ssh/info_refs_receive_pack') do |req, res|
+ server.mount_proc('/geo/proxy_git_ssh/info_refs_receive_pack') do |_req, res|
res.content_type = 'application/json'
res.status = 200
- res.body = {"result" => "#{Base64.encode64('custom')}"}.to_json
+ res.body = { "result" => Base64.encode64('custom').to_s }.to_json
end
server.mount_proc('/geo/proxy_git_ssh/receive_pack') do |req, res|
@@ -28,7 +28,7 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
output = JSON.parse(req.body)['output']
- res.body = {"result" => output}.to_json
+ res.body = { "result" => output }.to_json
end
server.mount_proc('/api/v4/internal/allowed') do |req, res|
@@ -51,11 +51,11 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
"action" => "geo_proxy_to_primary",
"data" => {
"api_endpoints" => ["/geo/proxy_git_ssh/info_refs_receive_pack", "/geo/proxy_git_ssh/receive_pack"],
- "gl_username" => "custom",
- "primary_repo" => "https://repo/path"
- },
+ "gl_username" => "custom",
+ "primary_repo" => "https://repo/path"
+ }
},
- "gl_console_messages" => ["console", "message"]
+ "gl_console_messages" => %w[console message]
}
res.body = body.to_json
else
@@ -103,7 +103,7 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
let(:cmd) { "#{gitlab_shell_path} key-101" }
it 'custom action is not performed' do
- Open3.popen2e(env, cmd) do |stdin, stdout|
+ Open3.popen2e(env, cmd) do |_stdin, stdout|
expect(stdout.gets).to eq("remote: \n")
expect(stdout.gets).to eq(divider)
expect(stdout.gets).to eq("remote: \n")
diff --git a/spec/gitlab_shell_custom_git_upload_pack_spec.rb b/spec/gitlab_shell_custom_git_upload_pack_spec.rb
index 6770344..d31a793 100644
--- a/spec/gitlab_shell_custom_git_upload_pack_spec.rb
+++ b/spec/gitlab_shell_custom_git_upload_pack_spec.rb
@@ -7,7 +7,7 @@ require 'base64'
describe 'Custom bin/gitlab-shell git-upload-pack' do
include_context 'gitlab shell'
- let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-upload-pack group/repo' } }
+ let(:env) { { 'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-upload-pack group/repo' } }
let(:divider) { "remote: ========================================================================\n" }
before(:context) do
@@ -15,11 +15,11 @@ describe 'Custom bin/gitlab-shell git-upload-pack' do
end
def mock_server(server)
- server.mount_proc('/geo/proxy_git_ssh/info_refs_upload_pack') do |req, res|
+ server.mount_proc('/geo/proxy_git_ssh/info_refs_upload_pack') do |_req, res|
res.content_type = 'application/json'
res.status = 200
- res.body = {"result" => "#{Base64.encode64('custom')}"}.to_json
+ res.body = { "result" => Base64.encode64('custom').to_s }.to_json
end
server.mount_proc('/geo/proxy_git_ssh/upload_pack') do |req, res|
@@ -28,7 +28,7 @@ describe 'Custom bin/gitlab-shell git-upload-pack' do
output = JSON.parse(req.body)['output']
- res.body = {"result" => output}.to_json
+ res.body = { "result" => output }.to_json
end
server.mount_proc('/api/v4/internal/allowed') do |req, res|
@@ -51,11 +51,11 @@ describe 'Custom bin/gitlab-shell git-upload-pack' do
"action" => "geo_proxy_to_primary",
"data" => {
"api_endpoints" => ["/geo/proxy_git_ssh/info_refs_upload_pack", "/geo/proxy_git_ssh/upload_pack"],
- "gl_username" => "custom",
- "primary_repo" => "https://repo/path"
- },
+ "gl_username" => "custom",
+ "primary_repo" => "https://repo/path"
+ }
},
- "gl_console_messages" => ["console", "message"]
+ "gl_console_messages" => %w[console message]
}
res.body = body.to_json
else
@@ -103,7 +103,7 @@ describe 'Custom bin/gitlab-shell git-upload-pack' do
let(:cmd) { "#{gitlab_shell_path} key-101" }
it 'custom action is not performed' do
- Open3.popen2e(env, cmd) do |stdin, stdout|
+ Open3.popen2e(env, cmd) do |_stdin, stdout|
expect(stdout.gets).to eq("remote: \n")
expect(stdout.gets).to eq(divider)
expect(stdout.gets).to eq("remote: \n")
diff --git a/spec/gitlab_shell_discover_spec.rb b/spec/gitlab_shell_discover_spec.rb
index ea99067..5431f5b 100644
--- a/spec/gitlab_shell_discover_spec.rb
+++ b/spec/gitlab_shell_discover_spec.rb
@@ -30,7 +30,7 @@ describe 'bin/gitlab-shell' do
end
end
- def run!(args, env: {'SSH_CONNECTION' => 'fake'})
+ def run!(args, env: { 'SSH_CONNECTION' => 'fake' })
cmd = [
gitlab_shell_path,
args
@@ -85,7 +85,7 @@ describe 'bin/gitlab-shell' do
end
it 'gets an ArgumentError on invalid input (multiple unknown)' do
- _, stderr, status = run!(["this", "is", "all", "invalid"])
+ _, stderr, status = run!(%w[this is all invalid])
expect(stderr).to match(/who='' is invalid/)
expect(status).not_to be_success
@@ -101,7 +101,7 @@ describe 'bin/gitlab-shell' do
end
it 'succeeds and prints username when a valid known username is given in the middle of other input' do
- output, _, status = run!(["-c/usr/share/webapps/gitlab-shell/bin/gitlab-shell", "username-someuser" ,"foo"])
+ output, _, status = run!(["-c/usr/share/webapps/gitlab-shell/bin/gitlab-shell", "username-someuser", "foo"])
expect(output).to eq("Welcome to GitLab, @someuser!\n")
expect(status).to be_success
diff --git a/spec/gitlab_shell_lfs_authentication_spec.rb b/spec/gitlab_shell_lfs_authentication_spec.rb
index 437005c..072761f 100644
--- a/spec/gitlab_shell_lfs_authentication_spec.rb
+++ b/spec/gitlab_shell_lfs_authentication_spec.rb
@@ -6,7 +6,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
include_context 'gitlab shell'
let(:path) { "https://gitlab.com/repo/path" }
- let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo download' } }
+ let(:env) { { 'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo download' } }
before(:context) do
write_config("gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}")
@@ -45,7 +45,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
when '100', 'someone' then
res.status = 200
res.body = '{"gl_id":"user-100", "status":true}'
- when '101' then
+ when '101'
res.status = 200
res.body = '{"gl_id":"user-101", "status":true}'
else
@@ -56,13 +56,13 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
describe 'lfs authentication command' do
def successful_response
- {
+ format("%s\n", {
"header" => {
"Authorization" => "Basic am9objpzb21ldG9rZW4="
},
"href" => "#{path}/info/lfs",
"expires_in" => 1800
- }.to_json + "\n"
+ }.to_json)
end
context 'when the command is allowed' do
@@ -70,7 +70,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
let(:cmd) { "#{gitlab_shell_path} key-100" }
it 'lfs is successfully authenticated' do
- output, stderr, status = Open3.capture3(env, cmd)
+ output, _stderr, status = Open3.capture3(env, cmd)
expect(output).to eq(successful_response)
expect(status).to be_success
@@ -81,7 +81,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
let(:cmd) { "#{gitlab_shell_path} username-someone" }
it 'lfs is successfully authenticated' do
- output, stderr, status = Open3.capture3(env, cmd)
+ output, _stderr, status = Open3.capture3(env, cmd)
expect(output).to eq(successful_response)
expect(status).to be_success
@@ -114,7 +114,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
context 'when an action for lfs authentication is unknown' do
let(:cmd) { "#{gitlab_shell_path} key-100" }
- let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo unknown' } }
+ let(:env) { { 'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo unknown' } }
it 'the command is disallowed' do
divider = "remote: \nremote: ========================================================================\nremote: \n"
diff --git a/spec/gitlab_shell_personal_access_token_spec.rb b/spec/gitlab_shell_personal_access_token_spec.rb
index 64bc34b..9c40528 100644
--- a/spec/gitlab_shell_personal_access_token_spec.rb
+++ b/spec/gitlab_shell_personal_access_token_spec.rb
@@ -17,19 +17,19 @@ describe 'bin/gitlab-shell personal_access_token' do
res.content_type = 'application/json'
res.status = 200
- if params['key_id'] == '000'
- res.body = { success: false, message: "Something wrong!"}.to_json
- else
- res.body = {
- success: true,
- token: 'aAY1G3YPeemECgUvxuXY',
- scopes: params['scopes'],
- expires_at: (params['expires_at'] && '9001-12-01')
- }.to_json
- end
+ res.body = if params['key_id'] == '000'
+ { success: false, message: "Something wrong!" }.to_json
+ else
+ {
+ success: true,
+ token: 'aAY1G3YPeemECgUvxuXY',
+ scopes: params['scopes'],
+ expires_at: (params['expires_at'] && '9001-12-01')
+ }.to_json
+ end
end
- server.mount_proc('/api/v4/internal/discover') do |req, res|
+ server.mount_proc('/api/v4/internal/discover') do |_req, res|
res.status = 200
res.content_type = 'application/json'
res.body = '{"id":100, "name": "Some User", "username": "someuser"}'
@@ -41,10 +41,10 @@ describe 'bin/gitlab-shell personal_access_token' do
let(:output) do
env = {
- 'SSH_CONNECTION' => 'fake',
+ 'SSH_CONNECTION' => 'fake',
'SSH_ORIGINAL_COMMAND' => "personal_access_token #{args}"
}
- Open3.popen2e(env, "#{gitlab_shell_path} #{key_id}")[1].read()
+ Open3.popen2e(env, "#{gitlab_shell_path} #{key_id}")[1].read
end
let(:help_message) do
diff --git a/spec/gitlab_shell_two_factor_recovery_spec.rb b/spec/gitlab_shell_two_factor_recovery_spec.rb
index ba7f997..b455905 100644
--- a/spec/gitlab_shell_two_factor_recovery_spec.rb
+++ b/spec/gitlab_shell_two_factor_recovery_spec.rb
@@ -5,14 +5,14 @@ require 'open3'
describe 'bin/gitlab-shell 2fa_recovery_codes' do
include_context 'gitlab shell'
- let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => '2fa_recovery_codes' } }
+ let(:env) { { 'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => '2fa_recovery_codes' } }
before(:context) do
write_config("gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}")
end
def mock_server(server)
- server.mount_proc('/api/v4/internal/two_factor_recovery_codes') do |req, res|
+ server.mount_proc('/api/v4/internal/two_factor_recovery_codes') do |_req, res|
res.content_type = 'application/json'
res.status = 200
@@ -30,7 +30,7 @@ describe 'bin/gitlab-shell 2fa_recovery_codes' do
end
end
- server.mount_proc('/api/v4/internal/discover') do |req, res|
+ server.mount_proc('/api/v4/internal/discover') do |_req, res|
res.status = 200
res.content_type = 'application/json'
res.body = '{"id":100, "name": "Some User", "username": "someuser"}'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 0939883..c605c3d 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,6 +1,6 @@
ROOT_PATH = File.expand_path('..', __dir__)
-Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
+Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |f| require f }
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
diff --git a/spec/support/gitlab_shell_setup.rb b/spec/support/gitlab_shell_setup.rb
index 6982aaa..ffc311a 100644
--- a/spec/support/gitlab_shell_setup.rb
+++ b/spec/support/gitlab_shell_setup.rb
@@ -22,7 +22,7 @@ RSpec.shared_context 'gitlab shell', shared_context: :metadata do
@tmp_root_path ||= File.realpath(Dir.mktmpdir)
end
- def mock_server(server)
+ def mock_server(_server)
raise NotImplementedError.new(
'mock_server method must be implemented in order to include gitlab shell context'
)
@@ -48,6 +48,7 @@ RSpec.shared_context 'gitlab shell', shared_context: :metadata do
sleep(0.1) while @webrick_thread.alive? && @server.status != :Running
raise "Couldn't start stub GitlabNet server" unless @server.status == :Running
+
system(original_root_path, 'bin/compile')
FileUtils.rm_rf(File.join(tmp_root_path, 'bin'))
@@ -55,8 +56,8 @@ RSpec.shared_context 'gitlab shell', shared_context: :metadata do
end
after(:all) do
- @server.shutdown if @server
- @webrick_thread.join if @webrick_thread
+ @server&.shutdown
+ @webrick_thread&.join
FileUtils.rm_rf(tmp_root_path)
end
end
diff --git a/spec/support/http_unix_server.rb b/spec/support/http_unix_server.rb
index 113df57..7371636 100644
--- a/spec/support/http_unix_server.rb
+++ b/spec/support/http_unix_server.rb
@@ -8,7 +8,7 @@ class HTTPUNIXServer < WEBrick::HTTPServer
super(config.merge(Logger: null_log, AccessLog: null_log))
end
- def listen(address, port)
+ def listen(address, _port)
socket = Socket.unix_server_socket(address)
socket.autoclose = false
server = UNIXServer.for_fd(socket.fileno)
@@ -16,20 +16,10 @@ class HTTPUNIXServer < WEBrick::HTTPServer
@listeners << server
end
- # Workaround:
- # https://bugs.ruby-lang.org/issues/10956
- # Affecting Ruby 2.2
- # Fix for 2.2 is at https://github.com/ruby/ruby/commit/ab0a64e1
- # However, this doesn't work with 2.1. The following should work for both:
- def start(&block)
- @shutdown_pipe = IO.pipe
- shutdown_pipe = @shutdown_pipe
- super(&block)
- end
-
def cleanup_shutdown_pipe(shutdown_pipe)
@shutdown_pipe = nil
- return if !shutdown_pipe
+ return unless shutdown_pipe
+
super(shutdown_pipe)
end
end