Commit 8f9046aa authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Update rubocop and code to pass it

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 9850a74b
...@@ -76,14 +76,6 @@ Style/BlockEndNewline: ...@@ -76,14 +76,6 @@ Style/BlockEndNewline:
Description: 'Put end statement of multiline block on its own line.' Description: 'Put end statement of multiline block on its own line.'
Enabled: true Enabled: true
Style/Blocks:
Description: >-
Avoid using {...} for multi-line blocks (multiline chaining is
always ugly).
Prefer {...} over do...end for single-line blocks.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
Enabled: true
Style/BracesAroundHashParameters: Style/BracesAroundHashParameters:
Description: 'Enforce braces style around hash parameters.' Description: 'Enforce braces style around hash parameters.'
Enabled: false Enabled: false
...@@ -152,7 +144,7 @@ Style/DefWithParentheses: ...@@ -152,7 +144,7 @@ Style/DefWithParentheses:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
Enabled: false Enabled: false
Style/DeprecatedHashMethods: Style/PreferredHashMethods:
Description: 'Checks for use of deprecated Hash methods.' Description: 'Checks for use of deprecated Hash methods.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
Enabled: false Enabled: false
...@@ -326,7 +318,7 @@ Style/LineEndConcatenation: ...@@ -326,7 +318,7 @@ Style/LineEndConcatenation:
line end. line end.
Enabled: false Enabled: false
Style/MethodCallParentheses: Style/MethodCallWithoutArgsParentheses:
Description: 'Do not use parentheses for method calls with no arguments.' Description: 'Do not use parentheses for method calls with no arguments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
Enabled: false Enabled: false
...@@ -528,7 +520,7 @@ Style/SingleLineMethods: ...@@ -528,7 +520,7 @@ Style/SingleLineMethods:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
Enabled: false Enabled: false
Style/SingleSpaceBeforeFirstArg: Layout/SpaceBeforeFirstArg:
Description: >- Description: >-
Checks that exactly one space is used between a method name Checks that exactly one space is used between a method name
and the first argument for method calls without parentheses. and the first argument for method calls without parentheses.
...@@ -544,7 +536,7 @@ Style/SpaceAfterComma: ...@@ -544,7 +536,7 @@ Style/SpaceAfterComma:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
Enabled: false Enabled: false
Style/SpaceAfterControlKeyword: Layout/SpaceAroundKeyword:
Description: 'Use spaces after if/elsif/unless/while/until/case/when.' Description: 'Use spaces after if/elsif/unless/while/until/case/when.'
Enabled: false Enabled: false
...@@ -605,7 +597,7 @@ Style/SpaceAroundOperators: ...@@ -605,7 +597,7 @@ Style/SpaceAroundOperators:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
Enabled: false Enabled: false
Style/SpaceBeforeModifierKeyword: Layout/SpaceAroundKeyword:
Description: 'Put a space before the modifier keyword.' Description: 'Put a space before the modifier keyword.'
Enabled: false Enabled: false
...@@ -659,7 +651,7 @@ Style/TrailingBlankLines: ...@@ -659,7 +651,7 @@ Style/TrailingBlankLines:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof'
Enabled: true Enabled: true
Style/TrailingComma: Style/TrailingCommaInLiteral:
Description: 'Checks for trailing comma in parameter lists and literals.' Description: 'Checks for trailing comma in parameter lists and literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false Enabled: false
...@@ -690,11 +682,6 @@ Style/UnneededPercentQ: ...@@ -690,11 +682,6 @@ Style/UnneededPercentQ:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
Enabled: false Enabled: false
Style/UnneededPercentX:
Description: 'Checks for %x when `` would do.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-x'
Enabled: false
Style/VariableInterpolation: Style/VariableInterpolation:
Description: >- Description: >-
Don't interpolate global, instance and class variables Don't interpolate global, instance and class variables
...@@ -896,7 +883,7 @@ Lint/ShadowingOuterLocalVariable: ...@@ -896,7 +883,7 @@ Lint/ShadowingOuterLocalVariable:
for block arguments or block local variables. for block arguments or block local variables.
Enabled: false Enabled: false
Lint/SpaceBeforeFirstArg: Layout/SpaceBeforeFirstArg:
Description: >- Description: >-
Put a space between a method name and the first argument Put a space between a method name and the first argument
in a method call without parentheses. in a method call without parentheses.
...@@ -968,3 +955,4 @@ AllCops: ...@@ -968,3 +955,4 @@ AllCops:
- 'lib/gitlab/upgrader.rb' - 'lib/gitlab/upgrader.rb'
- 'lib/gitlab/seeder.rb' - 'lib/gitlab/seeder.rb'
- 'lib/vendor/**/*' - 'lib/vendor/**/*'
- 'Guardfile'
source "http://rubygems.org" source "http://rubygems.org"
group :development, :test do group :development, :test do
gem 'simplecov', require: false
gem 'rspec', '~> 2.14.0'
gem 'webmock'
gem 'guard' gem 'guard'
gem 'guard-rspec' gem 'guard-rspec'
gem 'vcr' gem 'rspec', '~> 2.14.0'
gem 'rubocop', '0.49.1', require: false gem 'rubocop', '0.49.1', require: false
gem 'simplecov', require: false
gem 'vcr'
gem 'webmock'
end end
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# will be processed properly. # will be processed properly.
refs = $stdin.read refs = $stdin.read
key_id = ENV.delete('GL_ID') key_id = ENV.delete('GL_ID')
gl_repository = ENV.delete('GL_REPOSITORY') gl_repository = ENV.delete('GL_REPOSITORY')
repo_path = Dir.pwd repo_path = Dir.pwd
......
...@@ -157,8 +157,8 @@ class GitlabKeys ...@@ -157,8 +157,8 @@ class GitlabKeys
end end
def open_auth_file(mode) def open_auth_file(mode)
open(auth_file, mode, 0600) do |file| open(auth_file, mode, 0o600) do |file|
file.chmod(0600) file.chmod(0o600)
yield file yield file
end end
end end
......
...@@ -28,9 +28,9 @@ class GitlabNet ...@@ -28,9 +28,9 @@ class GitlabNet
} }
if actor =~ /\Akey\-\d+\Z/ if actor =~ /\Akey\-\d+\Z/
params.merge!(key_id: actor.gsub("key-", "")) params[:key_id] = actor.gsub("key-", "")
elsif actor =~ /\Auser\-\d+\Z/ elsif actor =~ /\Auser\-\d+\Z/
params.merge!(user_id: actor.gsub("user-", "")) params[:user_id] = actor.gsub("user-", "")
end end
url = "#{host}/allowed" url = "#{host}/allowed"
...@@ -141,7 +141,7 @@ class GitlabNet ...@@ -141,7 +141,7 @@ class GitlabNet
protected protected
def sanitize_path(repo) def sanitize_path(repo)
repo.gsub("'", "") repo.delete("'")
end end
def config def config
...@@ -153,11 +153,11 @@ class GitlabNet ...@@ -153,11 +153,11 @@ class GitlabNet
end end
def http_client_for(uri, options={}) def http_client_for(uri, options={})
if uri.is_a?(URI::HTTPUNIX) http = if uri.is_a?(URI::HTTPUNIX)
http = Net::HTTPUNIX.new(uri.hostname) Net::HTTPUNIX.new(uri.hostname)
else else
http = Net::HTTP.new(uri.host, uri.port) Net::HTTP.new(uri.host, uri.port)
end end
http.read_timeout = options[:read_timeout] || read_timeout http.read_timeout = options[:read_timeout] || read_timeout
......
...@@ -13,7 +13,8 @@ class GitlabPostReceive ...@@ -13,7 +13,8 @@ class GitlabPostReceive
def initialize(gl_repository, repo_path, actor, changes) def initialize(gl_repository, repo_path, actor, changes)
@config = GitlabConfig.new @config = GitlabConfig.new
@gl_repository = gl_repository @gl_repository = gl_repository
@repo_path, @actor = repo_path.strip, actor @repo_path = repo_path.strip
@actor = actor
@changes = changes @changes = changes
@jid = SecureRandom.hex(12) @jid = SecureRandom.hex(12)
end end
...@@ -47,11 +48,12 @@ class GitlabPostReceive ...@@ -47,11 +48,12 @@ class GitlabPostReceive
end end
def print_merge_request_link(merge_request) def print_merge_request_link(merge_request)
if merge_request["new_merge_request"] message =
message = "To create a merge request for #{merge_request["branch_name"]}, visit:" if merge_request["new_merge_request"]
else "To create a merge request for #{merge_request["branch_name"]}, visit:"
message = "View merge request for #{merge_request["branch_name"]}:" else
end "View merge request for #{merge_request["branch_name"]}:"
end
puts message puts message
puts((" " * 2) + merge_request["url"]) puts((" " * 2) + merge_request["url"])
...@@ -64,7 +66,7 @@ class GitlabPostReceive ...@@ -64,7 +66,7 @@ class GitlabPostReceive
# Git prefixes remote messages with "remote: ", so this width is subtracted # Git prefixes remote messages with "remote: ", so this width is subtracted
# from the width available to us. # 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, # 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. # so we add some horizontal padding: 2 chars on either side.
......
...@@ -13,8 +13,8 @@ class GitlabShell ...@@ -13,8 +13,8 @@ class GitlabShell
GITALY_MIGRATED_COMMANDS = { GITALY_MIGRATED_COMMANDS = {
'git-upload-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-upload-pack'), 'git-upload-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-upload-pack'),
'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack'), 'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack'),
} }.freeze
API_COMMANDS = %w(2fa_recovery_codes) API_COMMANDS = %w(2fa_recovery_codes).freeze
GL_PROTOCOL = 'ssh'.freeze GL_PROTOCOL = 'ssh'.freeze
attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :username attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :username
......
...@@ -32,7 +32,7 @@ module Net ...@@ -32,7 +32,7 @@ module Net
class HTTPUNIX < HTTP class HTTPUNIX < HTTP
def initialize(socketpath, port=nil) def initialize(socketpath, port=nil)
super(socketpath, port) 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 end
# override to prevent ":<port>" being appended to HTTP_HOST # override to prevent ":<port>" being appended to HTTP_HOST
......
...@@ -6,14 +6,14 @@ require 'fileutils' ...@@ -6,14 +6,14 @@ require 'fileutils'
require_relative '../lib/gitlab_init' require_relative '../lib/gitlab_init'
module GoBuild module GoBuild
GO_DIR = 'go' GO_DIR = 'go'.freeze
BUILD_DIR = File.join(ROOT_PATH, 'go_build') BUILD_DIR = File.join(ROOT_PATH, 'go_build')
GO_PACKAGE = File.join('gitlab.com/gitlab-org/gitlab-shell', GO_DIR) GO_PACKAGE = File.join('gitlab.com/gitlab-org/gitlab-shell', GO_DIR)
GO_ENV = { GO_ENV = {
'GOPATH' => BUILD_DIR, 'GOPATH' => BUILD_DIR,
'GO15VENDOREXPERIMENT' => '1', 'GO15VENDOREXPERIMENT' => '1',
} }.freeze
def create_fresh_build_dir def create_fresh_build_dir
FileUtils.rm_rf(BUILD_DIR) FileUtils.rm_rf(BUILD_DIR)
...@@ -25,7 +25,7 @@ module GoBuild ...@@ -25,7 +25,7 @@ module GoBuild
def run!(env, cmd) def run!(env, cmd)
raise "env must be a hash" unless env.is_a?(Hash) raise "env must be a hash" unless env.is_a?(Hash)
raise "cmd must be an array" unless cmd.is_a?(Array) raise "cmd must be an array" unless cmd.is_a?(Array)
if !system(env, *cmd) if !system(env, *cmd)
abort "command failed: #{env.inspect} #{cmd.join(' ')}" abort "command failed: #{env.inspect} #{cmd.join(' ')}"
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment