Skip to content
Snippets Groups Projects
Commit 11c45905 authored by Ian Baum's avatar Ian Baum Committed by DJ Mountney
Browse files

Upgrade rubocop to 0.73.0

* Add rubocop-rails and rubocop-performance gems
* Update renamed gems in .rubocop.yml
* Auto-correct where possible
* Manually fix remaining gems
parent 39d1b55d
No related branches found
No related tags found
No related merge requests found
Showing
with 81 additions and 94 deletions
require:
- rubocop-performance
- rubocop-rspec
- ./lib/rubocop/rubocop
 
Loading
Loading
@@ -26,10 +27,6 @@ AllCops:
 
Style/NumericLiteralPrefix:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/LineLength:
Enabled: false
 
# Gems in consecutive lines should be alphabetically sorted
Bundler/OrderedGems:
Loading
Loading
@@ -54,6 +51,10 @@ Layout/AlignHash:
Layout/AlignParameters:
Enabled: false
 
# Align block ends correctly.
Layout/BlockAlignment:
Enabled: true
# Put end statement of multiline block on its own line.
Layout/BlockEndNewline:
Enabled: true
Loading
Loading
@@ -66,6 +67,14 @@ Layout/CaseIndentation:
Layout/CommentIndentation:
Enabled: true
 
# Checks for condition placed in a confusing position relative to the keyword.
Layout/ConditionPosition:
Enabled: true
# Align ends corresponding to defs correctly.
Layout/DefEndAlignment:
Enabled: true
# Align elses and elsifs correctly.
Layout/ElseAlignment:
Enabled: true
Loading
Loading
@@ -102,6 +111,10 @@ Layout/EmptyLinesAroundMethodBody:
Layout/EmptyLinesAroundModuleBody:
Enabled: true
 
# Align ends correctly.
Layout/EndAlignment:
Enabled: true
# Use Unix-style line endings.
Layout/EndOfLine:
Enabled: true
Loading
Loading
@@ -407,10 +420,6 @@ Style/EvalWithLocation:
Style/EvenOdd:
Enabled: true
 
# Checks for flip flops.
Style/FlipFlop:
Enabled: true
# Checks use of for or each in multiline loops.
Style/For:
Enabled: true
Loading
Loading
@@ -537,6 +546,10 @@ Style/RedundantException:
Style/RedundantParentheses:
Enabled: true
 
# Use `sort` instead of `sort_by { |x| x }`.
Style/RedundantSortBy:
Enabled: true
Style/RegexpLiteral:
Enabled: false
 
Loading
Loading
@@ -574,12 +587,18 @@ Style/StringMethods:
intern: to_sym
Enabled: true
 
# Use `strip` instead of `lstrip.rstrip`.
Style/Strip:
Enabled: true
# Use %i or %I for arrays of symbols.
Style/SymbolArray:
Enabled: false
 
# This cop checks for trailing comma in array and hash literals.
Style/TrailingCommaInLiteral:
# These cops check for trailing comma in array and hash literals.
Style/TrailingCommaInArrayLiteral:
Enabled: false
Style/TrailingCommaInHashLiteral:
Enabled: false
 
# Checks for %W when interpolation is not needed.
Loading
Loading
@@ -685,27 +704,15 @@ Lint/AmbiguousRegexpLiteral:
Lint/AssignmentInCondition:
Enabled: false
 
# Align block ends correctly.
Lint/BlockAlignment:
Enabled: true
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
Enabled: true
 
# Checks for condition placed in a confusing position relative to the keyword.
Lint/ConditionPosition:
Enabled: true
# Check for debugger calls.
Lint/Debugger:
Enabled: true
 
# Align ends corresponding to defs correctly.
Lint/DefEndAlignment:
Enabled: true
# Check for deprecated class method calls.
Lint/DeprecatedClassMethods:
Enabled: true
Loading
Loading
@@ -730,10 +737,6 @@ Lint/EmptyEnsure:
Lint/EmptyWhen:
Enabled: true
 
# Align ends correctly.
Lint/EndAlignment:
Enabled: true
# END blocks should not be placed inside method definitions.
Lint/EndInMethod:
Enabled: true
Loading
Loading
@@ -742,6 +745,10 @@ Lint/EndInMethod:
Lint/EnsureReturn:
Enabled: true
 
# Checks for flip flops.
Lint/FlipFlop:
Enabled: true
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
Enabled: true
Loading
Loading
@@ -829,7 +836,7 @@ Lint/UnifiedInteger:
# Checks for rubocop:disable comments that can be removed.
# Note: this cop is not disabled when disabling all cops.
# It must be explicitly disabled.
Lint/UnneededDisable:
Lint/UnneededCopDisableDirective:
Enabled: false
 
# This cop checks for unneeded usages of splat expansion
Loading
Loading
@@ -883,15 +890,6 @@ Performance/Casecmp:
Performance/DoubleStartEndWith:
Enabled: true
 
# Use `Hash#each_key` and `Hash#each_value` instead of
# `Hash#keys.each` and `Hash#values.each`.
Performance/HashEachMethods:
Enabled: false
# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
Enabled: true
# Use `Range#cover?` instead of `Range#include?`.
Performance/RangeInclude:
Enabled: true
Loading
Loading
@@ -912,10 +910,6 @@ Performance/RedundantMerge:
Enabled: true
MaxKeyValuePairs: 1
 
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
Enabled: true
# Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match` or `=~` when `MatchData` is not used.
Performance/RegexpMatch:
Enabled: true
Loading
Loading
Loading
Loading
@@ -38,7 +38,9 @@ gem 'google_drive'
gem 'http'
 
group :rubocop do
gem 'rubocop'
gem 'rubocop', '0.69.0'
gem 'rubocop-performance', '~> 1.3.0'
# gem 'rubocop-rails'
gem 'rubocop-rspec'
end
 
Loading
Loading
Loading
Loading
@@ -857,6 +857,7 @@ GEM
iniparse (1.4.4)
iostruct (0.0.4)
ipaddress (0.8.3)
jaro_winkler (1.5.3)
jmespath (1.4.0)
json (2.0.2)
json_pure (1.8.1)
Loading
Loading
@@ -911,8 +912,8 @@ GEM
rainbow (= 2.2.2)
rest-client (~> 2.0)
thor (~> 0.18)
parallel (1.12.1)
parser (2.5.0.2)
parallel (1.17.0)
parser (2.6.3.0)
ast (~> 2.4.0)
pedump (0.5.2)
awesome_print
Loading
Loading
@@ -921,7 +922,6 @@ GEM
progressbar
zhexdump (>= 0.0.2)
plist (3.5.0)
powerpack (0.1.1)
progressbar (1.10.0)
proxifier (1.0.3)
pry (0.12.2)
Loading
Loading
@@ -960,16 +960,18 @@ GEM
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.52.1)
rubocop (0.69.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.3.0)
rubocop (>= 0.68.0)
rubocop-rspec (1.12.0)
rubocop (>= 0.42.0)
ruby-progressbar (1.9.0)
ruby-progressbar (1.10.1)
serverspec (2.41.4)
multi_json
rspec (~> 3.0)
Loading
Loading
@@ -996,7 +998,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)
unicode-display_width (1.6.0)
uuidtools (2.1.5)
wmi-lite (1.0.2)
zhexdump (0.0.2)
Loading
Loading
@@ -1024,7 +1026,8 @@ DEPENDENCIES
rake
rspec
rspec_junit_formatter
rubocop
rubocop (= 0.69.0)
rubocop-performance (~> 1.3.0)
rubocop-rspec
thor (= 0.18.1)
 
Loading
Loading
---
title: Upgrade rubocop to 0.69.0
merge_request: 3473
author:
type: other
Loading
Loading
@@ -38,9 +38,7 @@ build do
 
# Append the 1024bit Verisign certs so that S3 continues to work
block do
unless File.foreach("#{project_dir}/cacert-#{version.tr('.', '-')}.pem").grep(/^Verisign Class 3 Public Primary Certification Authority$/).any?
File.open("#{project_dir}/cacert-#{version.tr('.', '-')}.pem", 'a') { |fd| fd.write(VERISIGN_CERTS) }
end
File.open("#{project_dir}/cacert-#{version.tr('.', '-')}.pem", 'a') { |fd| fd.write(VERISIGN_CERTS) } unless File.foreach("#{project_dir}/cacert-#{version.tr('.', '-')}.pem").grep(/^Verisign Class 3 Public Primary Certification Authority$/).any?
end
 
copy "#{project_dir}/cacert-#{version.tr('.', '-')}.pem", "#{install_dir}/embedded/ssl/certs/cacert.pem"
Loading
Loading
Loading
Loading
@@ -51,7 +51,7 @@ build do
env = with_standard_compiler_flags(with_embedded_path)
 
block do
open(File.join(project_dir, 'config.mak'), 'a') do |file|
File.open(File.join(project_dir, 'config.mak'), 'a') do |file|
file.print <<-EOH
# Added by Omnibus git software definition git.rb
CURLDIR=#{install_dir}/embedded
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ build do
command "mkdir -p #{install_dir}/bin/"
 
block do
open("#{install_dir}/bin/gitlab-ctl", 'w') do |file|
File.open("#{install_dir}/bin/gitlab-ctl", 'w') do |file|
file.print <<-EOH
#!/bin/bash
#
Loading
Loading
@@ -69,7 +69,7 @@ done
export SVWAIT=30
 
#{install_dir}/embedded/bin/omnibus-ctl #{File.basename(install_dir)} '#{install_dir}/embedded/service/omnibus-ctl*' "$@"
EOH
EOH
end
end
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
 
build do
block do
open("#{install_dir}/bin/gitlab-geo-psql", 'w') do |file|
File.open("#{install_dir}/bin/gitlab-geo-psql", 'w') do |file|
file.print <<-EOH
#!/bin/sh
 
Loading
Loading
@@ -58,7 +58,7 @@ else
fi
 
cd /tmp; exec /opt/gitlab/embedded/bin/chpst ${privilege_drop} -U ${psql_user} /usr/bin/env PGSSLCOMPRESSION=0 /opt/gitlab/embedded/bin/psql -p ${psql_port} -h ${psql_host} -d ${psql_dbname} "$@"
EOH
EOH
end
end
 
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
 
build do
block do
open("#{install_dir}/bin/gitlab-healthcheck", 'w') do |file|
File.open("#{install_dir}/bin/gitlab-healthcheck", 'w') do |file|
file.print <<-EOH
#!/bin/sh
 
Loading
Loading
@@ -47,7 +47,7 @@ fi
. ${gitlab_healthcheck_rc}
 
exec /opt/gitlab/embedded/bin/curl $@ ${flags} ${url}
EOH
EOH
end
end
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
 
build do
block do
open("#{install_dir}/embedded/bin/gitlab-pg-ctl", 'w') do |file|
File.open("#{install_dir}/embedded/bin/gitlab-pg-ctl", 'w') do |file|
file.print <<-EOH
#!/bin/sh
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ default_version Digest::MD5.file(__FILE__).hexdigest
 
build do
block do
open("#{install_dir}/bin/gitlab-psql", 'w') do |file|
File.open("#{install_dir}/bin/gitlab-psql", 'w') do |file|
file.print <<-EOH
#!/bin/sh
 
Loading
Loading
@@ -58,7 +58,7 @@ else
fi
 
cd /tmp; exec /opt/gitlab/embedded/bin/chpst ${privilege_drop} -U ${psql_user} /usr/bin/env PGSSLCOMPRESSION=0 /opt/gitlab/embedded/bin/psql -p ${psql_port} -h ${psql_host} -d ${psql_dbname} "$@"
EOH
EOH
end
end
 
Loading
Loading
Loading
Loading
@@ -41,9 +41,7 @@ build do
config_flags = ""
# CentOS 6 doesn't have inotify, which will raise an error
# IN_EXCL_UNLINK undeclared. Hence disabling it explicitly.
if ohai['platform'] =~ /centos/ && ohai['platform_version'] =~ /^6/
config_flags = "ac_cv_func_inotify_init=no"
end
config_flags = "ac_cv_func_inotify_init=no" if ohai['platform'] =~ /centos/ && ohai['platform_version'] =~ /^6/
 
command './configure ' \
"--prefix=#{install_dir}/embedded --disable-doc --without-readline --disable-sqlite --disable-gnutls --disable-dirmngr #{config_flags}", env: env
Loading
Loading
# Copyright 2012-2014 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Loading
Loading
@@ -41,9 +40,7 @@ build do
 
# The patch is from the FreeBSD ports tree and is for GCC compatibility.
# http://svnweb.freebsd.org/ports/head/devel/libedit/files/patch-vi.c?annotate=300896
if version.to_i < 20_150_325 && (freebsd? || openbsd?)
patch source: 'freebsd-vi-fix.patch', env: env
end
patch source: 'freebsd-vi-fix.patch', env: env if version.to_i < 20_150_325 && (freebsd? || openbsd?)
 
patch source: 'openbsd-weak-alias-fix.patch', plevel: 1, env: env if openbsd?
 
Loading
Loading
Loading
Loading
@@ -39,9 +39,7 @@ build do
 
# Windows had worse automake/libtool version issues.
# Just patch the output instead.
if version >= '0.1.6' && windows?
patch source: 'v0.1.6.windows-configure.patch', plevel: 1, env: env
end
patch source: 'v0.1.6.windows-configure.patch', plevel: 1, env: env if version >= '0.1.6' && windows?
 
make "-j #{workers}", env: env
make "-j #{workers} install", env: env
Loading
Loading
Loading
Loading
@@ -90,9 +90,7 @@ build do
 
patch source: 'patch-ncurses_tinfo_lib__baudrate.c', plevel: 0 if openbsd?
 
if version == '5.9' && ppc64le?
patch source: 'v5.9.ppc64le-configure.patch', plevel: 1
end
patch source: 'v5.9.ppc64le-configure.patch', plevel: 1 if version == '5.9' && ppc64le?
 
configure_command = [
'./configure',
Loading
Loading
@@ -153,9 +151,7 @@ build do
make "-j #{workers} install", env: env
 
# Ensure embedded ncurses wins in the LD search path
if smartos?
link "#{install_dir}/embedded/lib/libcurses.so", "#{install_dir}/embedded/lib/libcurses.so.1"
end
link "#{install_dir}/embedded/lib/libcurses.so", "#{install_dir}/embedded/lib/libcurses.so.1" if smartos?
end
 
project.exclude "embedded/bin/ncurses5-config"
Loading
Loading
Loading
Loading
@@ -34,9 +34,7 @@ build do
 
update_config_guess
 
if version == '1.7.10.1' && (ppc64? || ppc64le?)
patch source: 'v1.7.10.1.ppc64le-configure.patch', plevel: 1
end
patch source: 'v1.7.10.1.ppc64le-configure.patch', plevel: 1 if version == '1.7.10.1' && (ppc64? || ppc64le?)
 
# --disable-nls => Disable localization support.
command './configure' \
Loading
Loading
Loading
Loading
@@ -115,9 +115,7 @@ build do
# wrlinux7/ios_xr build boxes from Cisco include libssp and there is no way to
# disable ruby from linking against it, but Cisco switches will not have the
# library. Disabling it as we do for Solaris.
if ios_xr? && version.satisfies?('>= 2.1')
patch source: 'ruby-no-stack-protector.patch', plevel: 1, env: patch_env
end
patch source: 'ruby-no-stack-protector.patch', plevel: 1, env: patch_env if ios_xr? && version.satisfies?('>= 2.1')
 
# disable libpath in mkmf across all platforms, it trolls omnibus and
# breaks the postgresql cookbook. i'm not sure why ruby authors decided
Loading
Loading
@@ -217,6 +215,7 @@ build do
arch_suffix = windows_arch_i386? ? '32' : '64'
windows_path = "C:/msys2/mingw#{arch_suffix}/bin/#{dll}.dll"
raise "Cannot find required DLL needed for dynamic linking: #{windows_path}" unless File.exist?(windows_path)
copy windows_path, "#{install_dir}/embedded/bin/#{dll}.dll"
end
end
Loading
Loading
Loading
Loading
@@ -22,9 +22,9 @@ action :create do
 
content = {
'service' => {
'name' => service_name,
'name' => service_name,
'address' => ip_address,
'port' => port.to_i
'port' => port.to_i
}
}
 
Loading
Loading
Loading
Loading
@@ -16,14 +16,14 @@ class GitlabGeoHelper # rubocop:disable Style/MultilineIfModifier (disabled so w
end
 
def db_migrate_status_file
@migrate_status_file ||= begin
@db_migrate_status_file ||= begin
upgrade_status_dir = ::File.join(node['gitlab']['gitlab-rails']['dir'], 'upgrade-status')
::File.join(upgrade_status_dir, "geo-db-migrate-#{connection_digest}-#{revision}")
end
end
 
def fdw_sync_status_file
@sync_status_file ||= begin
@fdw_sync_status_file ||= begin
upgrade_status_dir = ::File.join(node['gitlab']['gitlab-rails']['dir'], 'upgrade-status')
::File.join(upgrade_status_dir, "geo-fdw-sync-#{connection_digest}-#{revision}")
end
Loading
Loading
class SentinelHelper
MYID_PATTERN ||= /^[0-9a-f]{40}$/
MYID_PATTERN ||= /^[0-9a-f]{40}$/.freeze
JSON_FILE ||= '/etc/gitlab/gitlab-sentinel.json'.freeze
 
def initialize(node)
Loading
Loading
@@ -18,9 +18,7 @@ class SentinelHelper
 
# Restore from node definition (gitlab.rb)
def restore_from_node
unless MYID_PATTERN.match?(sentinel['myid'])
raise 'Sentinel myid must be exactly 40 hex-characters lowercase'
end
raise 'Sentinel myid must be exactly 40 hex-characters lowercase' unless MYID_PATTERN.match?(sentinel['myid'])
 
sentinel['myid']
end
Loading
Loading
@@ -50,6 +48,7 @@ class SentinelHelper
# Save to local JSON file
def save_to_file(data)
return unless File.directory?('/etc/gitlab')
File.open(JSON_FILE, 'w', 0600) do |f|
f.puts(Chef::JSONCompat.to_json_pretty(data))
f.chmod(0600) # update existing file
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment