Skip to content

Commit 301ef73

Browse files
committed
(CONT-786) Rubocop unsafe Auto Fixes 1-3
- Lint/NonAtomicFileOperation - Performance/StringInclude - Performance/UnfreezeString
1 parent b50d002 commit 301ef73

File tree

5 files changed

+5
-24
lines changed

5 files changed

+5
-24
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ Lint/DuplicateBranch:
1212
Exclude:
1313
- 'tooling/kube_tool/other_params.rb'
1414

15-
# Offense count: 2
16-
# This cop supports unsafe autocorrection (--autocorrect-all).
17-
Lint/NonAtomicFileOperation:
18-
Exclude:
19-
- 'tooling/kube_tool/clean_up.rb'
20-
- 'tooling/kube_tool/create_certs.rb'
21-
2215
# Offense count: 1
2316
# Configuration parameters: AllowedPatterns.
2417
# AllowedPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times)
@@ -88,18 +81,6 @@ Naming/MethodParameterName:
8881
Naming/VariableName:
8982
Enabled: false
9083

91-
# Offense count: 1
92-
# This cop supports unsafe autocorrection (--autocorrect-all).
93-
Performance/StringInclude:
94-
Exclude:
95-
- 'spec/spec_helper_acceptance_local.rb'
96-
97-
# Offense count: 2
98-
# This cop supports unsafe autocorrection (--autocorrect-all).
99-
Performance/UnfreezeString:
100-
Exclude:
101-
- 'tooling/kube_tool/other_params.rb'
102-
10384
# Offense count: 16
10485
# Configuration parameters: Prefixes, AllowedPatterns.
10586
# Prefixes: when, with, without

spec/spec_helper_acceptance_local.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def execute_agent(role)
249249
run_shell('sudo apt install docker.io -y')
250250
run_shell('systemctl start docker.service')
251251
run_shell('systemctl enable docker.service')
252-
if %r{ubuntu-1604-lts}.match?(family)
252+
if family.include?('ubuntu-1604-lts')
253253
run_shell('sudo ufw disable')
254254
else
255255
# Workaround for debian as the strech repositories do not have updated kubernetes packages

tooling/kube_tool/clean_up.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class CleanUp
55
def self.all(files)
66
files.each do |x|
7-
FileUtils.rm_f(x) if File.exist?(x)
7+
FileUtils.rm_f(x)
88
end
99
end
1010

tooling/kube_tool/create_certs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def etcd_certificates
5656
server = servers.split(':')
5757
hostname = server[0]
5858
ip = server[1]
59-
FileUtils.rm_f("#{hostname}.yaml") if File.exist?("#{hostname}.yaml")
59+
FileUtils.rm_f("#{hostname}.yaml")
6060
puts 'Creating etcd peer and server certificates'
6161
csr = { CN: "etcd-#{hostname}", hosts: etcd_server_ips, key: { algo: @opts[:ca_algo], size: @opts[:key_size] } }
6262
File.write('config.json', csr.to_json)

tooling/kube_tool/other_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def self.create(opts)
4141
end
4242

4343
x = opts[:etcd_initial_cluster].split(',')
44-
cluster = String.new
45-
peers = String.new
44+
cluster = +''
45+
peers = +''
4646
bootstrap_controller = x[0]
4747
z = bootstrap_controller.split(':')
4848
controller_address = "#{z[1]}:6443"

0 commit comments

Comments
 (0)