summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-02-22 18:17:29 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-02-22 18:17:29 +0200
commit8f9046aad854e4c861c3a016cc3dd69e137a5c27 (patch)
tree1837825ba2cb3cf6e2c805a3354825e4737b9616 /lib
parent9850a74ba6093ecc771f53cb9abd7c9c8a59f266 (diff)
downloadgitlab-shell-8f9046aad854e4c861c3a016cc3dd69e137a5c27.tar.gz
Update rubocop and code to pass it
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_keys.rb4
-rw-r--r--lib/gitlab_net.rb16
-rw-r--r--lib/gitlab_post_receive.rb16
-rw-r--r--lib/gitlab_shell.rb4
-rw-r--r--lib/httpunix.rb2
5 files changed, 22 insertions, 20 deletions
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 975ee3e..e6dfd99 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -157,8 +157,8 @@ class GitlabKeys
end
def open_auth_file(mode)
- open(auth_file, mode, 0600) do |file|
- file.chmod(0600)
+ open(auth_file, mode, 0o600) do |file|
+ file.chmod(0o600)
yield file
end
end
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 3f8c280..9a88b4b 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -28,9 +28,9 @@ class GitlabNet
}
if actor =~ /\Akey\-\d+\Z/
- params.merge!(key_id: actor.gsub("key-", ""))
+ params[:key_id] = actor.gsub("key-", "")
elsif actor =~ /\Auser\-\d+\Z/
- params.merge!(user_id: actor.gsub("user-", ""))
+ params[:user_id] = actor.gsub("user-", "")
end
url = "#{host}/allowed"
@@ -141,7 +141,7 @@ class GitlabNet
protected
def sanitize_path(repo)
- repo.gsub("'", "")
+ repo.delete("'")
end
def config
@@ -153,11 +153,11 @@ class GitlabNet
end
def http_client_for(uri, options={})
- if uri.is_a?(URI::HTTPUNIX)
- http = Net::HTTPUNIX.new(uri.hostname)
- else
- http = Net::HTTP.new(uri.host, uri.port)
- end
+ http = if uri.is_a?(URI::HTTPUNIX)
+ Net::HTTPUNIX.new(uri.hostname)
+ else
+ Net::HTTP.new(uri.host, uri.port)
+ end
http.read_timeout = options[:read_timeout] || read_timeout
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb
index 55b00bb..bd289b7 100644
--- a/lib/gitlab_post_receive.rb
+++ b/lib/gitlab_post_receive.rb
@@ -13,7 +13,8 @@ class GitlabPostReceive
def initialize(gl_repository, repo_path, actor, changes)
@config = GitlabConfig.new
@gl_repository = gl_repository
- @repo_path, @actor = repo_path.strip, actor
+ @repo_path = repo_path.strip
+ @actor = actor
@changes = changes
@jid = SecureRandom.hex(12)
end
@@ -47,11 +48,12 @@ class GitlabPostReceive
end
def print_merge_request_link(merge_request)
- if merge_request["new_merge_request"]
- message = "To create a merge request for #{merge_request["branch_name"]}, visit:"
- else
- message = "View merge request for #{merge_request["branch_name"]}:"
- end
+ message =
+ if merge_request["new_merge_request"]
+ "To create a merge request for #{merge_request["branch_name"]}, visit:"
+ else
+ "View merge request for #{merge_request["branch_name"]}:"
+ end
puts message
puts((" " * 2) + merge_request["url"])
@@ -64,7 +66,7 @@ class GitlabPostReceive
# Git prefixes remote messages with "remote: ", so this width is subtracted
# from the width available to us.
- total_width -= "remote: ".length
+ total_width -= "remote: ".length # rubocop:disable Performance/FixedSize
# Our centered text shouldn't start or end right at the edge of the window,
# so we add some horizontal padding: 2 chars on either side.
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 1452f95..0d2531f 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -13,8 +13,8 @@ class GitlabShell
GITALY_MIGRATED_COMMANDS = {
'git-upload-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-upload-pack'),
'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack'),
- }
- API_COMMANDS = %w(2fa_recovery_codes)
+ }.freeze
+ API_COMMANDS = %w(2fa_recovery_codes).freeze
GL_PROTOCOL = 'ssh'.freeze
attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :username
diff --git a/lib/httpunix.rb b/lib/httpunix.rb
index 12787ee..db160eb 100644
--- a/lib/httpunix.rb
+++ b/lib/httpunix.rb
@@ -32,7 +32,7 @@ module Net
class HTTPUNIX < HTTP
def initialize(socketpath, port=nil)
super(socketpath, port)
- @port = nil # HTTP will set it to default - override back -> set DEFAULT_PORT
+ @port = nil # HTTP will set it to default - override back -> set DEFAULT_PORT
end
# override to prevent ":<port>" being appended to HTTP_HOST