Skip to content

Commit ad2191e

Browse files
committed
(CONT-789) Rubocop Auto Fixes 1-5
- Layout/ArgumentAlignment - Layout/BeginEndAlignment - Layout/ClosingHeredocIndentation - Layout/EmptyLineAfterGuardClause - Layout/HashAlignment
1 parent 5459176 commit ad2191e

22 files changed

+92
-133
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,6 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 10
10-
# This cop supports safe autocorrection (--autocorrect).
11-
# Configuration parameters: EnforcedStyle, IndentationWidth.
12-
# SupportedStyles: with_first_argument, with_fixed_indentation
13-
Layout/ArgumentAlignment:
14-
Exclude:
15-
- 'spec/unit/puppet/provider/mysql_login_path/mysql_login_path_spec.rb'
16-
- 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb'
17-
18-
# Offense count: 1
19-
# This cop supports safe autocorrection (--autocorrect).
20-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
21-
# SupportedStylesAlignWith: start_of_line, begin
22-
Layout/BeginEndAlignment:
23-
Exclude:
24-
- 'lib/puppet/provider/mysql_login_path/inifile.rb'
25-
26-
# Offense count: 6
27-
# This cop supports safe autocorrection (--autocorrect).
28-
Layout/ClosingHeredocIndentation:
29-
Exclude:
30-
- 'lib/puppet/type/mysql_datadir.rb'
31-
- 'lib/puppet/type/mysql_grant.rb'
32-
- 'lib/puppet/type/mysql_login_path.rb'
33-
- 'lib/puppet/type/mysql_user.rb'
34-
- 'spec/acceptance/00_mysql_server_spec.rb'
35-
- 'spec/classes/mysql_server_account_security_spec.rb'
36-
37-
# Offense count: 18
38-
# This cop supports safe autocorrection (--autocorrect).
39-
Layout/EmptyLineAfterGuardClause:
40-
Exclude:
41-
- 'lib/puppet/functions/mysql/normalise_and_deepmerge.rb'
42-
- 'lib/puppet/provider/mysql.rb'
43-
- 'lib/puppet/provider/mysql_datadir/mysql.rb'
44-
- 'lib/puppet/provider/mysql_grant/mysql.rb'
45-
- 'lib/puppet/provider/mysql_login_path/inifile.rb'
46-
- 'lib/puppet/provider/mysql_user/mysql.rb'
47-
- 'lib/puppet/type/mysql_grant.rb'
48-
- 'spec/classes/mysql_bindings_spec.rb'
49-
- 'tasks/export.rb'
50-
- 'tasks/sql.rb'
51-
52-
# Offense count: 54
53-
# This cop supports safe autocorrection (--autocorrect).
54-
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
55-
# SupportedHashRocketStyles: key, separator, table
56-
# SupportedColonStyles: key, separator, table
57-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
58-
Layout/HashAlignment:
59-
Exclude:
60-
- 'lib/puppet/type/mysql_login_path.rb'
61-
- 'spec/classes/mysql_backup_mysqldump_spec.rb'
62-
- 'spec/classes/mysql_bindings_spec.rb'
63-
- 'spec/classes/mysql_server_backup_spec.rb'
64-
- 'spec/classes/mysql_server_spec.rb'
65-
- 'spec/defines/mysql_db_spec.rb'
66-
- 'spec/unit/puppet/provider/mysql_login_path/mysql_login_path_spec.rb'
67-
689
# Offense count: 2
6910
# This cop supports safe autocorrection (--autocorrect).
7011
Layout/HeredocIndentation:

lib/puppet/functions/mysql/normalise_and_deepmerge.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ def normalise_and_deepmerge(*args)
4747
def normalized?(hash, key)
4848
return true if hash.key?(key)
4949
return false unless %r{-|_}.match?(key)
50+
5051
other_key = key.include?('-') ? key.tr('-', '_') : key.tr('_', '-')
5152
return false unless hash.key?(other_key)
53+
5254
hash[key] = hash.delete(other_key)
5355
true
5456
end
@@ -65,6 +67,7 @@ def overlay(hash1, hash2)
6567

6668
def deep_copy(inputhash)
6769
return inputhash unless inputhash.is_a? Hash
70+
6871
hash = {}
6972
inputhash.each do |k, v|
7073
hash.store(k, deep_copy(v))

lib/puppet/provider/mysql.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def self.cmd_table(table)
158158

159159
def self.cmd_privs(privileges)
160160
return 'ALL PRIVILEGES' if privileges.include?('ALL')
161+
161162
priv_string = ''
162163
privileges.each do |priv|
163164
priv_string += "#{priv}, "

lib/puppet/provider/mysql_datadir/mysql.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def create
5050
unless File.exist?(defaults_extra_file)
5151
raise ArgumentError, _('Defaults-extra-file %{file} is missing.') % { file: defaults_extra_file }
5252
end
53+
5354
defaults_extra_file = "--defaults-extra-file=#{defaults_extra_file}"
5455
end
5556

lib/puppet/provider/mysql_grant/mysql.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def self.instances
2020
# of myhost.mydomain.my: root@myhost.mydomain.my, when MySQL is started
2121
# with --skip-name-resolve.
2222
next if %r{There is no such grant defined for user}.match?(e.inspect)
23+
2324
raise Puppet::Error, _('#mysql had an error -> %{inspect}') % { inspect: e.inspect }
2425
end
2526
# Once we have the list of grants generate entries for each.
@@ -28,6 +29,7 @@ def self.instances
2829
munged_grant = grant.delete("'").delete('`').delete('"')
2930
# Matching: GRANT (SELECT, UPDATE) PRIVILEGES ON (*.*) TO ('root')@('127.0.0.1') (WITH GRANT OPTION)
3031
next unless match = munged_grant.match(%r{^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)?$}) # rubocop:disable Lint/AssignmentInCondition
32+
3133
privileges, table, user, host, rest = match.captures
3234
table.gsub!('\\\\', '\\')
3335

lib/puppet/provider/mysql_login_path/inifile.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Error < StandardError; end
3030
# Returns an IniFile instance or nil if the file could not be opened.
3131
def self.load(filename, opts = {})
3232
return unless File.file? filename
33+
3334
new(opts.merge(filename: filename))
3435
end
3536

@@ -220,6 +221,7 @@ def merge!(other)
220221
# Returns this IniFile.
221222
def each
222223
return unless block_given?
224+
223225
@ini.each do |section, hash|
224226
hash.each do |param, val|
225227
yield section, param, val
@@ -242,6 +244,7 @@ def each
242244
# Returns this IniFile.
243245
def each_section
244246
return unless block_given?
247+
245248
@ini.each_key { |section| yield section }
246249
self
247250
end
@@ -268,6 +271,7 @@ def delete_section(section)
268271
# Returns the Hash of parameter/value pairs for this section.
269272
def [](section)
270273
return nil if section.nil?
274+
271275
@ini[section.to_s]
272276
end
273277

@@ -373,6 +377,7 @@ def clone
373377
def eql?(other)
374378
return true if equal? other
375379
return false unless other.instance_of? self.class
380+
376381
@ini == other.instance_variable_get(:@ini)
377382
end
378383
alias == eql?
@@ -609,10 +614,10 @@ def typecast(value)
609614
else
610615
begin
611616
begin
612-
Integer(value)
617+
Integer(value)
613618
rescue
614619
Float(value)
615-
end
620+
end
616621
rescue
617622
unescape_value(value)
618623
end

lib/puppet/provider/mysql_user/mysql.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def password_hash=(string)
154154
self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system')
155155
elsif newer_than('mariadb' => '10.1.21') && plugin == 'ed25519'
156156
raise ArgumentError, _('ed25519 hash should be 43 bytes long.') unless string.length == 43
157+
157158
# ALTER USER statement is only available upstream starting 10.2
158159
# https://mariadb.com/kb/en/mariadb-1020-release-notes/
159160
if newer_than('mariadb' => '10.2.0')
@@ -167,6 +168,7 @@ def password_hash=(string)
167168
self.class.mysql_caller(sql, 'system')
168169
elsif newer_than('mysql' => '5.7.6', 'percona' => '5.7.6', 'mariadb' => '10.2.0')
169170
raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) hashes are supported.') unless %r{^\*|^$}.match?(string)
171+
170172
self.class.mysql_caller("ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'", 'system')
171173
else
172174
self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system')

lib/puppet/type/mysql_datadir.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Manage MySQL datadirs with mysql_install_db OR mysqld (5.7.6 and above).
77
88
@api private
9-
PUPPET
9+
PUPPET
1010

1111
ensurable
1212

lib/puppet/type/mysql_grant.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@doc = <<-PUPPET
55
@summary
66
Manage a MySQL user's rights.
7-
PUPPET
7+
PUPPET
88
ensurable
99

1010
autorequire(:file) { '/root/.my.cnf' }
@@ -39,6 +39,7 @@ def initialize(*args)
3939
raise(_('mysql_grant: `privileges` `parameter`: PROXY can only be specified by itself.')) if Array(self[:privileges]).size > 1 && Array(self[:privileges]).include?('PROXY')
4040
raise(_('mysql_grant: `table` `parameter` is required.')) if self[:ensure] == :present && self[:table].nil?
4141
raise(_('mysql_grant: `user` `parameter` is required.')) if self[:ensure] == :present && self[:user].nil?
42+
4243
if self[:user] && self[:table]
4344
raise(_('mysql_grant: `name` `parameter` must match user@host/table format.')) if self[:name] != "#{self[:user]}/#{self[:table]}"
4445
end

lib/puppet/type/mysql_login_path.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
3232
This type provides Puppet with the capabilities to store authentication credentials in an obfuscated login path file
3333
named .mylogin.cnf created with the mysql_config_editor utility. Supports only MySQL Community Edition > v5.6.6.
34-
EOS
34+
EOS
3535
features: ['simple_get_filter', 'canonicalize'],
3636
title_patterns: [
3737
{
@@ -45,39 +45,39 @@
4545
],
4646
attributes: {
4747
ensure: {
48-
type: 'Enum[present, absent]',
49-
desc: 'Whether this resource should be present or absent on the target system.',
48+
type: 'Enum[present, absent]',
49+
desc: 'Whether this resource should be present or absent on the target system.',
5050
},
5151
name: {
52-
type: 'String',
53-
desc: 'Name of the login path you want to manage.',
52+
type: 'String',
53+
desc: 'Name of the login path you want to manage.',
5454
behaviour: :namevar,
5555
},
5656
owner: {
57-
type: 'String',
58-
desc: 'The user to whom the logon path should belong.',
57+
type: 'String',
58+
desc: 'The user to whom the logon path should belong.',
5959
behaviour: :namevar,
60-
default: 'root',
60+
default: 'root',
6161
},
6262
host: {
63-
type: 'Optional[String]',
64-
desc: 'Host name to be entered into the login path.',
63+
type: 'Optional[String]',
64+
desc: 'Host name to be entered into the login path.',
6565
},
6666
user: {
67-
type: 'Optional[String]',
68-
desc: 'Username to be entered into the login path.',
67+
type: 'Optional[String]',
68+
desc: 'Username to be entered into the login path.',
6969
},
7070
password: {
71-
type: 'Optional[Sensitive[String[1]]]',
72-
desc: 'Password to be entered into login path',
71+
type: 'Optional[Sensitive[String[1]]]',
72+
desc: 'Password to be entered into login path',
7373
},
7474
socket: {
75-
type: 'Optional[String]',
76-
desc: 'Socket path to be entered into login path',
75+
type: 'Optional[String]',
76+
desc: 'Socket path to be entered into login path',
7777
},
7878
port: {
79-
type: 'Optional[Integer[0,65535]]',
80-
desc: 'Port number to be entered into login path.',
79+
type: 'Optional[Integer[0,65535]]',
80+
desc: 'Port number to be entered into login path.',
8181
},
8282
},
8383
)

lib/puppet/type/mysql_user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@doc = <<-PUPPET
66
@summary
77
Manage a MySQL user. This includes management of users password as well as privileges.
8-
PUPPET
8+
PUPPET
99

1010
ensurable
1111

spec/acceptance/00_mysql_server_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class { '::mysql::server':
5959
'log-bin' => '/var/log/mariadb/mariadb-bin.log',}
6060
}
6161
}
62-
MANIFEST
62+
MANIFEST
6363
end
6464

6565
it 'can be set' do

spec/classes/mysql_backup_mysqldump_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class { 'mysql::server': }
1515
end
1616

1717
let(:default_params) do
18-
{ 'backupuser' => 'testuser',
19-
'backuppassword' => 'testpass',
20-
'backupdir' => '/tmp/mysql-backup',
21-
'backuprotate' => '25',
18+
{ 'backupuser' => 'testuser',
19+
'backuppassword' => 'testpass',
20+
'backupdir' => '/tmp/mysql-backup',
21+
'backuprotate' => '25',
2222
'delete_before_dump' => true,
23-
'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
24-
'maxallowedpacket' => '1M' }
23+
'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
24+
'maxallowedpacket' => '1M' }
2525
end
2626

2727
context 'with time included' do
@@ -76,7 +76,7 @@ class { 'mysql::server': }
7676
let(:params) do
7777
{
7878
'file_per_database' => true,
79-
'excludedatabases' => [ 'information_schema' ],
79+
'excludedatabases' => [ 'information_schema' ],
8080
}.merge(default_params)
8181
end
8282

spec/classes/mysql_bindings_spec.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
describe 'mysql::bindings' do
66
on_supported_os.each do |os, facts|
77
next if facts[:os]['family'] == 'Archlinux'
8+
89
context "on #{os}" do
910
let(:facts) do
1011
facts.merge(root_home: '/root')
@@ -13,12 +14,12 @@
1314
let(:params) do
1415
{
1516
'java_enable' => true,
16-
'perl_enable' => true,
17-
'php_enable' => true,
18-
'python_enable' => true,
19-
'ruby_enable' => true,
20-
'client_dev' => true,
21-
'daemon_dev' => true,
17+
'perl_enable' => true,
18+
'php_enable' => true,
19+
'python_enable' => true,
20+
'ruby_enable' => true,
21+
'client_dev' => true,
22+
'daemon_dev' => true,
2223
'client_dev_package_name' => 'libmysqlclient-devel',
2324
'daemon_dev_package_name' => 'mysql-devel',
2425
}

spec/classes/mysql_server_account_security_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let(:pre_condition) do
99
<<-EOF
1010
anchor {'mysql::server::end': }
11-
EOF
11+
EOF
1212
end
1313

1414
context 'with fqdn==myhost.mydomain' do

spec/classes/mysql_server_backup_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class { 'mysql::server': }
1515
end
1616

1717
let(:default_params) do
18-
{ 'backupuser' => 'testuser',
19-
'backuppassword' => 'testpass',
20-
'backupdir' => '/tmp/mysql-backup',
21-
'backuprotate' => '25',
18+
{ 'backupuser' => 'testuser',
19+
'backuppassword' => 'testpass',
20+
'backupdir' => '/tmp/mysql-backup',
21+
'backuprotate' => '25',
2222
'delete_before_dump' => true,
23-
'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
24-
'maxallowedpacket' => '1M' }
23+
'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
24+
'maxallowedpacket' => '1M' }
2525
end
2626

2727
context 'standard conditions' do
@@ -122,7 +122,7 @@ class { 'mysql::server': }
122122
context 'with delete after dump and custom success file path' do
123123
let(:custom_params) do
124124
{
125-
'delete_before_dump' => false,
125+
'delete_before_dump' => false,
126126
'backup_success_file_path' => '/opt/mysqlbackup_success',
127127
}
128128
end

0 commit comments

Comments
 (0)