Skip to content

Commit 5a76927

Browse files
committed
(CONT-789) Rubocop Unsafe Autocorrect 4-6
- RSpec/VerifiedDoubleReference - Style/CaseLikeIf - Style/CommentedKeyword
1 parent 00255c7 commit 5a76927

File tree

5 files changed

+18
-37
lines changed

5 files changed

+18
-37
lines changed

.rubocop_todo.yml

-21
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,6 @@ RSpec/StubbedMock:
155155
- 'spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb'
156156
- 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb'
157157

158-
# Offense count: 3
159-
# This cop supports unsafe autocorrection (--autocorrect-all).
160-
# Configuration parameters: .
161-
# SupportedStyles: constant, string
162-
RSpec/VerifiedDoubleReference:
163-
EnforcedStyle: string
164-
165-
# Offense count: 3
166-
# This cop supports unsafe autocorrection (--autocorrect-all).
167-
# Configuration parameters: MinBranchesCount.
168-
Style/CaseLikeIf:
169-
Exclude:
170-
- 'lib/puppet/provider/mysql_user/mysql.rb'
171-
- 'spec/acceptance/types/mysql_plugin_spec.rb'
172-
173-
# Offense count: 1
174-
# This cop supports unsafe autocorrection (--autocorrect-all).
175-
Style/CommentedKeyword:
176-
Exclude:
177-
- 'lib/puppet/provider/mysql_login_path/inifile.rb'
178-
179158
# Offense count: 2
180159
# This cop supports unsafe autocorrection (--autocorrect-all).
181160
Style/GlobalStdStream:

lib/puppet/provider/mysql_login_path/inifile.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,4 @@ def unescape_value(value)
643643
value
644644
end
645645
end
646-
end # IniFile
646+
end

lib/puppet/provider/mysql_user/mysql.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ def self.instances
2323
else
2424
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
2525
end
26-
@max_user_connections, @max_connections_per_hour, @max_queries_per_hour,
27-
@max_updates_per_hour, ssl_type, ssl_cipher, x509_issuer, x509_subject,
28-
@password, @plugin, @authentication_string = mysql_caller(query, 'regular').chomp.split(%r{\t})
26+
@max_user_connections, @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, ssl_type, ssl_cipher,
27+
x509_issuer, x509_subject, @password, @plugin, @authentication_string = mysql_caller(query, 'regular').chomp.split(%r{\t})
2928
@tls_options = parse_tls_options(ssl_type, ssl_cipher, x509_issuer, x509_subject)
3029
if newer_than('mariadb' => '10.1.21') && (@plugin == 'ed25519' || @plugin == 'mysql_native_password')
3130
# Some auth plugins (e.g. ed25519) use authentication_string
@@ -256,11 +255,12 @@ def tls_options=(array)
256255
end
257256

258257
def self.parse_tls_options(ssl_type, ssl_cipher, x509_issuer, x509_subject)
259-
if ssl_type == 'ANY'
258+
case ssl_type
259+
when 'ANY'
260260
['SSL']
261-
elsif ssl_type == 'X509'
261+
when 'X509'
262262
['X509']
263-
elsif ssl_type == 'SPECIFIED'
263+
when 'SPECIFIED'
264264
options = []
265265
options << "CIPHER '#{ssl_cipher}'" if !ssl_cipher.nil? && !ssl_cipher.empty?
266266
options << "ISSUER '#{x509_issuer}'" if !x509_issuer.nil? && !x509_issuer.empty?

spec/acceptance/types/mysql_plugin_spec.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
# of mysql) have varying levels of support for plugins and have
77
# different plugins available. Choose a plugin that works or don't try
88
# to test plugins if not available.
9-
if os[:family] == 'redhat'
10-
if os[:release].to_i == 5
9+
case os[:family]
10+
when 'redhat'
11+
case os[:release].to_i
12+
when 5
1113
plugin = nil # Plugins not supported on mysql on RHEL 5
12-
elsif os[:release].to_i == 6
14+
when 6
1315
plugin = 'example'
1416
plugin_lib = 'ha_example.so'
15-
elsif os[:release].to_i == 7
17+
when 7
1618
plugin = 'pam'
1719
plugin_lib = 'auth_pam.so'
1820
end
19-
elsif os[:family] == 'debian'
21+
when 'debian'
2022
if os[:family] == 'ubuntu'
2123
if %r{^16\.04|^18\.04}.match?(os[:release])
2224
# On Xenial running 5.7.12, the example plugin does not appear to be available.
@@ -27,7 +29,7 @@
2729
plugin_lib = 'ha_example.so'
2830
end
2931
end
30-
elsif os[:family] == 'suse'
32+
when 'suse'
3133
plugin = nil # Plugin library path is broken on Suse http://lists.opensuse.org/opensuse-bugs/2013-08/msg01123.html
3234
end
3335

spec/unit/puppet/provider/mysql_login_path/mysql_login_path_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
RSpec.describe Puppet::Provider::MysqlLoginPath::MysqlLoginPath do
99
subject(:provider) { described_class.new }
1010

11-
let(:context) { instance_double('Puppet::ResourceApi::BaseContext') }
12-
let(:wait_thr) { instance_double('wait_thr') }
13-
let(:wait_thr_value) { instance_double('wait_thr_value') }
11+
let(:context) { instance_double(Puppet::ResourceApi::BaseContext) }
12+
let(:wait_thr) { instance_double(wait_thr) }
13+
let(:wait_thr_value) { instance_double(wait_thr_value) }
1414
let(:sensitive_secure) { Puppet::Provider::MysqlLoginPath::Sensitive.new('secure') }
1515
let(:sensitive_more_secure) { Puppet::Provider::MysqlLoginPath::Sensitive.new('more_secure') }
1616

0 commit comments

Comments
 (0)