Skip to content

Commit 16e09c3

Browse files
committed
(CONT-789) Rubocop Auto Fixes 6-10
- Layout/HeredocIndentation - Layout/LineEndStringConcatenationIndentation - Layout/SpaceInsideArrayLiteralBrackets - Lint/RedundantCopEnableDirective - RSpec/EmptyLineAfterExample
1 parent ad2191e commit 16e09c3

16 files changed

+79
-82
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +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: 2
10-
# This cop supports safe autocorrection (--autocorrect).
11-
Layout/HeredocIndentation:
12-
Exclude:
13-
- 'spec/unit/puppet/provider/mysql_database/mysql_spec.rb'
14-
- 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb'
15-
16-
# Offense count: 1
17-
# This cop supports safe autocorrection (--autocorrect).
18-
# Configuration parameters: EnforcedStyle, IndentationWidth.
19-
# SupportedStyles: aligned, indented
20-
Layout/LineEndStringConcatenationIndentation:
21-
Exclude:
22-
- 'spec/unit/puppet/provider/mysql_login_path/mysql_login_path_spec.rb'
23-
24-
# Offense count: 4
25-
# This cop supports safe autocorrection (--autocorrect).
26-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
27-
# SupportedStyles: space, no_space, compact
28-
# SupportedStylesForEmptyBrackets: space, no_space
29-
Layout/SpaceInsideArrayLiteralBrackets:
30-
Exclude:
31-
- 'spec/classes/mysql_backup_mysqldump_spec.rb'
32-
- 'spec/defines/mysql_db_spec.rb'
33-
349
# Offense count: 11
3510
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
3611
Lint/DuplicateBranch:
@@ -48,19 +23,6 @@ Lint/FloatComparison:
4823
Exclude:
4924
- 'spec/spec_helper_acceptance_local.rb'
5025

51-
# Offense count: 11
52-
# This cop supports safe autocorrection (--autocorrect).
53-
Lint/RedundantCopEnableDirective:
54-
Exclude:
55-
- 'spec/acceptance/types/mysql_grant_spec.rb'
56-
- 'spec/acceptance/types/mysql_user_spec.rb'
57-
- 'spec/classes/mysql_backup_mysqldump_spec.rb'
58-
- 'spec/classes/mysql_backup_xtrabackup_spec.rb'
59-
- 'spec/classes/mysql_server_backup_spec.rb'
60-
- 'spec/classes/mysql_server_spec.rb'
61-
- 'spec/unit/puppet/provider/mysql_database/mysql_spec.rb'
62-
- 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb'
63-
6426
# Offense count: 18
6527
Lint/ReturnInVoidContext:
6628
Exclude:
@@ -169,22 +131,6 @@ RSpec/ContextWording:
169131
RSpec/DescribeClass:
170132
Enabled: false
171133

172-
# Offense count: 60
173-
# This cop supports safe autocorrection (--autocorrect).
174-
# Configuration parameters: AllowConsecutiveOneLiners.
175-
RSpec/EmptyLineAfterExample:
176-
Exclude:
177-
- 'spec/acceptance/02_mysql_mariadb_spec.rb'
178-
- 'spec/acceptance/types/mysql_grant_spec.rb'
179-
- 'spec/acceptance/types/mysql_login_path_spec.rb'
180-
- 'spec/classes/mysql_server_backup_spec.rb'
181-
- 'spec/classes/mysql_server_spec.rb'
182-
- 'spec/functions/mysql_normalise_and_deepmerge_spec.rb'
183-
- 'spec/unit/puppet/provider/mysql_database/mysql_spec.rb'
184-
- 'spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb'
185-
- 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb'
186-
- 'spec/unit/puppet/type/mysql_grant_spec.rb'
187-
188134
# Offense count: 21
189135
# This cop supports safe autocorrection (--autocorrect).
190136
RSpec/EmptyLineAfterExampleGroup:

spec/acceptance/02_mysql_mariadb_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class { '::mysql::server':
3737
it 'apply manifest' do
3838
apply_manifest(pp)
3939
end
40+
4041
it 'mariadb connection' do
4142
result = run_shell('mysql --user="root" --password="strongpassword" -e "status"')
4243
expect(result.stdout).to match(%r{MariaDB})

spec/acceptance/types/mysql_grant_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,12 @@ class { 'mysql::server':
436436

437437
apply_manifest(pp, catch_failures: true)
438438
end
439-
# rubocop:enable RSpec/ExampleLength
439+
440440
it 'finds the user' do
441441
result = run_shell('mysql -NBe "SHOW GRANTS FOR test3@tester"')
442442
expect(result.stdout).to match(%r{GRANT EXECUTE ON FUNCTION `mysql`.`simplefunc` TO ['|`]test3['|`]@['|`]tester['|`]})
443443
expect(result.stderr).to be_empty
444444
end
445-
# rubocop:enable RSpec/MultipleExpectations
446445
end
447446

448447
describe 'proxy privilieges' do

spec/acceptance/types/mysql_login_path_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343
it 'works with no errors' do
4444
apply_manifest(pp, catch_failures: true)
4545
end
46+
4647
it 'finds mysql_config_editor binary for the provider' do
4748
run_shell('mysql_config_editor -V') do |r|
4849
expect(r.stdout).to match(%r{Ver.*#{mysql_version}.*x86_64})
4950
end
5051
end
52+
5153
it 'finds my_print_defaults binary for the provider' do
5254
run_shell('my_print_defaults -V') do |r|
5355
expect(r.exit_status).to eq(0)
@@ -78,6 +80,7 @@
7880
it 'works without errors' do
7981
apply_manifest(pp, catch_failures: true)
8082
end
83+
8184
it 'finds the login path #stdout' do
8285
run_shell('mysql_config_editor print --all') do |r|
8386
regex_match = [%r{^\[local_socket\]\n}, %r{host = localhost\n}, %r{user = root\n}, %r{socket = /var/run/mysql/mysql.sock\n},
@@ -88,6 +91,7 @@
8891
expect(r.stderr).to be_empty
8992
end
9093
end
94+
9195
it 'finds the login path password #stdout' do
9296
run_shell('my_print_defaults -s local_socket') do |r|
9397
expect(r.stdout).to match(%r{--password=secure\n})
@@ -118,6 +122,7 @@
118122
it 'works without errors' do
119123
apply_manifest(pp, catch_failures: true)
120124
end
125+
121126
it 'finds the login path #stdout' do
122127
run_shell('mysql_config_editor print -G local_tcp') do |r|
123128
regex_match = [%r{^\[local_tcp\]\n}, %r{host = 10.0.0.1\n}, %r{user = network2\n}, %r{port = 3307\n}]
@@ -127,6 +132,7 @@
127132
expect(r.stderr).to be_empty
128133
end
129134
end
135+
130136
it 'finds the login path password #stdout' do
131137
run_shell('my_print_defaults -s local_tcp') do |r|
132138
expect(r.stdout).to match(%r{--password=Fort_kn0X\n})
@@ -140,6 +146,7 @@
140146
it 'removes values' do
141147
apply_manifest(pp2, catch_failures: true)
142148
end
149+
143150
it 'ensure values are removed #stdout' do
144151
run_shell('mysql_config_editor print -G local_tcp') do |r|
145152
regex_match = [%r{^\[local_tcp\]\n}, %r{host = 192.168.0.1\n}]
@@ -153,6 +160,7 @@
153160
expect(r.stderr).to be_empty
154161
end
155162
end
163+
156164
it 'ensure password removed from the login path #stdout' do
157165
run_shell('my_print_defaults -s local_tcp') do |r|
158166
expect(r.stdout).not_to match(%r{--password=Fort_kn0X\n})
@@ -173,6 +181,7 @@
173181
it 'works without errors' do
174182
apply_manifest(pp, catch_failures: true)
175183
end
184+
176185
it 'finds the login path #stdout' do
177186
run_shell('mysql_config_editor print --all') do |r|
178187
expect(r.stdout).not_to match(%r{^\[local_socket\]\n})
@@ -198,6 +207,7 @@
198207
it 'works without errors' do
199208
apply_manifest(pp, catch_failures: true)
200209
end
210+
201211
it 'finds the login path #stdout' do
202212
run_shell('MYSQL_TEST_LOGIN_FILE=/home/loginpath_test/.mylogin.cnf mysql_config_editor print -G local_tcp') do |r|
203213
regex_match = [%r{^\[local_tcp\]\n}, %r{host = 10.0.0.2\n}, %r{user = other\n}, %r{port = 3306\n}]
@@ -207,6 +217,7 @@
207217
expect(r.stderr).to be_empty
208218
end
209219
end
220+
210221
it 'finds the login path password #stdout' do
211222
run_shell('MYSQL_TEST_LOGIN_FILE=/home/loginpath_test/.mylogin.cnf my_print_defaults print -s local_tcp') do |r|
212223
expect(r.stdout).to match(%r{--password=sensitive\n})
@@ -227,6 +238,7 @@
227238
it 'works without errors' do
228239
apply_manifest(pp, catch_failures: true)
229240
end
241+
230242
it 'finds the login path #stdout' do
231243
run_shell('MYSQL_TEST_LOGIN_FILE=/home/loginpath_test/.mylogin.cnf mysql_config_editor print -G local_tcp') do |r|
232244
regex_match = [%r{^\[local_tcp\]\n}, %r{host = 10.0.0.3\n}, %r{user = other2\n}, %r{port = 3307\n}]
@@ -236,6 +248,7 @@
236248
expect(r.stderr).to be_empty
237249
end
238250
end
251+
239252
it 'finds the login path password #stdout' do
240253
run_shell('MYSQL_TEST_LOGIN_FILE=/home/loginpath_test/.mylogin.cnf my_print_defaults -s local_tcp') do |r|
241254
expect(r.stdout).to match(%r{--password=password\n})
@@ -253,6 +266,7 @@
253266
it 'works without errors' do
254267
apply_manifest(pp, catch_failures: true)
255268
end
269+
256270
it 'finds the login path #stdout' do
257271
run_shell('MYSQL_TEST_LOGIN_FILE=/home/loginpath_test/.mylogin.cnf mysql_config_editor print --all') do |r|
258272
expect(r.stdout).not_to match(%r{^\[local_tcp\]\n})

spec/acceptance/types/mysql_user_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class { 'mysql::server': * => $ed25519_opts }
9595
end
9696
end
9797
end
98-
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations
9998
end
10099

101100
context 'using ashp-dash@localhost' do

spec/classes/mysql_backup_mysqldump_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -88,5 +88,4 @@ class { 'mysql::server': }
8888
end
8989
end
9090
end
91-
# rubocop:enable RSpec/NestedGroups
9291
end

spec/classes/mysql_backup_xtrabackup_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,4 @@ class { 'mysql::server': }
324324
end
325325
end
326326
end
327-
# rubocop:enable RSpec/NestedGroups
328327
end

spec/classes/mysql_server_backup_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ class { 'mysql::server': }
288288
it 'loops through backup all databases without compression #show databases' do
289289
is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*})
290290
end
291+
291292
it 'loops through backup all databases without compression #bzcat' do
292293
is_expected.to contain_file('mysqlbackup.sh').without_content(%r{.*bzcat -zc.*})
293294
end
@@ -386,5 +387,4 @@ class { 'mysql::server': }
386387
end
387388
end
388389
end
389-
# rubocop:enable RSpec/NestedGroups
390390
end

spec/classes/mysql_server_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
it 'contains the package by default' do
6868
is_expected.to contain_package('mysql-server').with(ensure: :present)
6969
end
70+
7071
context 'with package_manage set to true' do
7172
let(:params) { { package_manage: true } }
7273

@@ -120,6 +121,7 @@
120121
it do
121122
is_expected.to contain_service('mysqld').with(ensure: :stopped)
122123
end
124+
123125
context 'with package_manage set to true' do
124126
let(:params) { { package_manage: true } }
125127

@@ -170,13 +172,15 @@
170172
path: '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
171173
)
172174
}
175+
173176
it { is_expected.not_to contain_mysql_user('root@localhost') }
174177
it { is_expected.not_to contain_file('/root/.my.cnf') }
175178
end
176179
describe 'when root_password set' do
177180
let(:params) { { root_password: 'SET' } }
178181

179182
it { is_expected.to contain_mysql_user('root@localhost') }
183+
180184
if Puppet.version.to_f >= 3.0
181185
it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false).that_requires('Mysql_user[root@localhost]') }
182186
else
@@ -187,6 +191,7 @@
187191
let(:params) { { root_password: 'SET', create_root_user: false } }
188192

189193
it { is_expected.not_to contain_mysql_user('root@localhost') }
194+
190195
if Puppet.version.to_f >= 3.0
191196
it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false) }
192197
else
@@ -229,6 +234,7 @@
229234
password_hash: '*F3A2A51A9B0F2BE2468926B4132313728C250DBF'
230235
)
231236
}
237+
232238
it {
233239
is_expected.to contain_mysql_user('foo2@localhost').with(
234240
max_connections_per_hour: nil, max_queries_per_hour: nil,
@@ -284,6 +290,7 @@
284290
privileges: ['SELECT', 'UPDATE'], options: ['GRANT']
285291
)
286292
}
293+
287294
it {
288295
is_expected.to contain_mysql_grant('foo2@localhost/*.*').with(
289296
user: 'foo2@localhost', table: '*.*',
@@ -309,10 +316,10 @@
309316
collate: 'latin1',
310317
)
311318
}
319+
312320
it { is_expected.to contain_mysql_database('somedb2') }
313321
end
314322
end
315323
end
316324
end
317-
# rubocop:enable RSpec/NestedGroups
318325
end

spec/defines/mysql_db_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'mysql_exec_path' => '' }
1818
end
1919

20-
let(:sql) { [ '/tmp/test.sql' ] }
20+
let(:sql) { ['/tmp/test.sql'] }
2121

2222
it 'does not notify the import sql exec if no sql script was provided' do
2323
is_expected.to contain_mysql_database('test_db').without_notify

spec/functions/mysql_normalise_and_deepmerge_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
hash = subject.execute({ 'a-b-c' => 1 }, 'a_b_c' => 10)
7373
expect(hash['a_b_c']).to eq(10)
7474
end
75+
7576
it 'equates keys mod dash and underscore #not' do
7677
hash = subject.execute({ 'a-b-c' => 1 }, 'a_b_c' => 10)
7778
expect(hash).not_to have_key('a-b-c')
@@ -85,6 +86,7 @@
8586
hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 })
8687
expect(hash[index]).to eq(expected_values_five[expected])
8788
end
89+
8890
it 'keeps style of the last when keys are equal mod dash and underscore #not' do
8991
hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 })
9092
expect(hash).not_to have_key(index_values_error[expected])

spec/unit/puppet/provider/mysql_database/mysql_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
)
1616
end
1717
let(:raw_databases) do
18-
<<-SQL_OUTPUT
19-
information_schema
20-
mydb
21-
mysql
22-
performance_schema
23-
test
18+
<<~SQL_OUTPUT
19+
information_schema
20+
mydb
21+
mysql
22+
performance_schema
23+
test
2424
SQL_OUTPUT
25-
# rubocop:enable Layout/IndentHeredoc
2625
end
2726

2827
before :each do
@@ -81,6 +80,7 @@
8180
allow(File).to receive(:file?).with('/root/.my.cnf').and_return(true)
8281
expect(provider.defaults_file).to eq '--defaults-extra-file=/root/.my.cnf'
8382
end
83+
8484
it 'fails if file missing' do
8585
allow(File).to receive(:file?).with('/root/.my.cnf').and_return(false)
8686
expect(provider.defaults_file).to be_nil

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
allow(PTY).to receive(:spawn)
3030
.with({ 'HOME' => '/root' },
3131
'/usr/bin/mysql_config_editor set --skip-warn -G local_socket -h localhost -u root ' \
32-
'-S /var/run/mysql/mysql.sock -p')
32+
'-S /var/run/mysql/mysql.sock -p')
3333
.and_return(`(exit 0)`)
3434

3535
allow(PTY).to receive(:spawn)

spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
allow(File).to receive(:file?).with('/root/.my.cnf').and_return(true)
5757
expect(provider.defaults_file).to eq '--defaults-extra-file=/root/.my.cnf'
5858
end
59+
5960
it 'fails if file missing' do
6061
allow(File).to receive(:file?).with('/root/.my.cnf').and_return(false)
6162
expect(provider.defaults_file).to be_nil

0 commit comments

Comments
 (0)