Skip to content

Commit 52e36b6

Browse files
committed
rubocop linting
1 parent e606493 commit 52e36b6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/puppet/functions/mysql/password.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
def password(password, sensitive = false)
2323
password = password.unwrap if password.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
2424

25-
result_string = if %r{\*[A-F0-9]{40}$}.match?(password) or %r{0x[A-F0-9]+$}.match?(password)
25+
result_string = if %r{\*[A-F0-9]{40}$}.match?(password) || %r{0x[A-F0-9]+$}.match?(password)
2626
password
2727
elsif password.empty?
2828
''

lib/puppet/provider/mysql_user/mysql.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def self.instances
2323
# rubocop:enable Layout/LineLength
2424
@max_user_connections, @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, ssl_type, ssl_cipher,
2525
x509_issuer, x509_subject, @password, @plugin, @authentication_string = mysql_caller(query, 'regular').chomp.split(%r{\t})
26-
26+
2727
if @plugin == 'caching_sha2_password'
2828
# Escaping all single quotes to prevent errors when password generated it
29-
@password = @password.gsub("'"){"\\'"}
29+
@password = @password.gsub("'") { "\\'" }
3030
@password = mysql_caller("SELECT CONCAT('0x',HEX('#{@password}'))", 'regular').chomp
3131
end
3232

@@ -83,7 +83,7 @@ def create
8383
if !plugin.nil?
8484
if password_hash.nil?
8585
self.class.mysql_caller("CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}'", 'system')
86-
elsif plugin.eql? "caching_sha2_password"
86+
elsif plugin.eql? 'caching_sha2_password'
8787
self.class.mysql_caller("CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}' AS X'#{password_hash[2..-1]}'", 'system')
8888
else
8989
self.class.mysql_caller("CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}' AS '#{password_hash}'", 'system')
@@ -168,12 +168,14 @@ def password_hash=(string)
168168
end
169169
self.class.mysql_caller(sql, 'system')
170170
elsif !mysqld_version.nil? && newer_than('mysql' => '5.7.6', 'percona' => '5.7.6', 'mariadb' => '10.2.0')
171-
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) or caching_sha2_password (0x1234ABC...XXX) hashes are supported.') unless %r{^\*|^$}.match?(string) || %r{0x[A-F0-9]+$}.match?(string)
171+
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) or caching_sha2_password (0x1234ABC...XXX) hashes are supported.') unless
172+
%r{^\*|^$}.match?(string) || %r{0x[A-F0-9]+$}.match?(string)
173+
172174
sql = "ALTER USER #{merged_name} IDENTIFIED WITH"
173175
if plugin == 'caching_sha2_password'
174-
sql += " 'caching_sha2_password' AS X'#{string[2..-1]}'"
176+
sql << " 'caching_sha2_password' AS X'#{string[2..-1]}'"
175177
else
176-
sql += " 'mysql_native_password' AS '#{string}'"
178+
sql << " 'mysql_native_password' AS '#{string}'"
177179
end
178180
self.class.mysql_caller(sql, 'system')
179181
else

0 commit comments

Comments
 (0)