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:
Description: 'Put end statement of multiline block on its own line.'
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:
Description: 'Enforce braces style around hash parameters.'
Enabled: false
......@@ -152,7 +144,7 @@ Style/DefWithParentheses:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
Enabled: false
Style/DeprecatedHashMethods:
Style/PreferredHashMethods:
Description: 'Checks for use of deprecated Hash methods.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
Enabled: false
......@@ -326,7 +318,7 @@ Style/LineEndConcatenation:
line end.
Enabled: false
Style/MethodCallParentheses:
Style/MethodCallWithoutArgsParentheses:
Description: 'Do not use parentheses for method calls with no arguments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
Enabled: false
......@@ -528,7 +520,7 @@ Style/SingleLineMethods:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
Enabled: false
Style/SingleSpaceBeforeFirstArg:
Layout/SpaceBeforeFirstArg:
Description: >-
Checks that exactly one space is used between a method name
and the first argument for method calls without parentheses.
......@@ -544,7 +536,7 @@ Style/SpaceAfterComma:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
Enabled: false
Style/SpaceAfterControlKeyword:
Layout/SpaceAroundKeyword:
Description: 'Use spaces after if/elsif/unless/while/until/case/when.'
Enabled: false
......@@ -605,7 +597,7 @@ Style/SpaceAroundOperators:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
Enabled: false
Style/SpaceBeforeModifierKeyword:
Layout/SpaceAroundKeyword:
Description: 'Put a space before the modifier keyword.'
Enabled: false
......@@ -659,7 +651,7 @@ Style/TrailingBlankLines:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof'
Enabled: true
Style/TrailingComma:
Style/TrailingCommaInLiteral:
Description: 'Checks for trailing comma in parameter lists and literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false
......@@ -690,11 +682,6 @@ Style/UnneededPercentQ:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
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:
Description: >-
Don't interpolate global, instance and class variables
......@@ -896,7 +883,7 @@ Lint/ShadowingOuterLocalVariable:
for block arguments or block local variables.
Enabled: false
Lint/SpaceBeforeFirstArg:
Layout/SpaceBeforeFirstArg:
Description: >-
Put a space between a method name and the first argument
in a method call without parentheses.
......@@ -968,3 +955,4 @@ AllCops:
- 'lib/gitlab/upgrader.rb'
- 'lib/gitlab/seeder.rb'
- 'lib/vendor/**/*'
- 'Guardfile'
source "http://rubygems.org"
group :development, :test do
gem 'simplecov', require: false
gem 'rspec', '~> 2.14.0'
gem 'webmock'
gem 'guard'
gem 'guard-rspec'
gem 'vcr'
gem 'rspec', '~> 2.14.0'
gem 'rubocop', '0.49.1', require: false
gem 'simplecov', require: false
gem 'vcr'
gem 'webmock'
end
......@@ -4,7 +4,7 @@
# will be processed properly.
refs = $stdin.read
key_id = ENV.delete('GL_ID')
key_id = ENV.delete('GL_ID')
gl_repository = ENV.delete('GL_REPOSITORY')
repo_path = Dir.pwd
......
......@@ -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
......
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
......@@ -6,14 +6,14 @@ require 'fileutils'
require_relative '../lib/gitlab_init'
module GoBuild
GO_DIR = 'go'
GO_DIR = 'go'.freeze
BUILD_DIR = File.join(ROOT_PATH, 'go_build')
GO_PACKAGE = File.join('gitlab.com/gitlab-org/gitlab-shell', GO_DIR)
GO_ENV = {
'GOPATH' => BUILD_DIR,
'GO15VENDOREXPERIMENT' => '1',
}
}.freeze
def create_fresh_build_dir
FileUtils.rm_rf(BUILD_DIR)
......@@ -25,7 +25,7 @@ module GoBuild
def run!(env, cmd)
raise "env must be a hash" unless env.is_a?(Hash)
raise "cmd must be an array" unless cmd.is_a?(Array)
if !system(env, *cmd)
abort "command failed: #{env.inspect} #{cmd.join(' ')}"
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