Skip to content

Commit 6918969

Browse files
committed
(CONT-789) Rubocop Auto Fixes 11-15
- RSpec/EmptyLineAfterExampleGroup - RSpec/EmptyLineAfterHook - RSpec/ExcessiveDocstringSpacing - RSpec/ImplicitSubject - Style/AccessorGrouping
1 parent 16e09c3 commit 6918969

21 files changed

+176
-184
lines changed

.rubocop_todo.yml

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-04-11 15:00:23 UTC using RuboCop version 1.48.1.
3+
# on 2023-04-12 10:15:38 UTC using RuboCop version 1.48.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -131,40 +131,20 @@ RSpec/ContextWording:
131131
RSpec/DescribeClass:
132132
Enabled: false
133133

134-
# Offense count: 21
135-
# This cop supports safe autocorrection (--autocorrect).
136-
RSpec/EmptyLineAfterExampleGroup:
137-
Exclude:
138-
- 'spec/acceptance/types/mysql_user_spec.rb'
139-
- 'spec/classes/mysql_server_spec.rb'
140-
141-
# Offense count: 6
142-
# This cop supports safe autocorrection (--autocorrect).
143-
# Configuration parameters: AllowConsecutiveOneLiners.
144-
RSpec/EmptyLineAfterHook:
145-
Exclude:
146-
- 'spec/unit/facter/mysql_server_id_spec.rb'
147-
- 'spec/unit/facter/mysql_version_spec.rb'
148-
- 'spec/unit/facter/mysqld_version_spec.rb'
149-
- 'spec/unit/puppet/provider/mysql_database/mysql_spec.rb'
150-
151-
# Offense count: 32
134+
# Offense count: 33
152135
# Configuration parameters: CountAsOne.
153136
RSpec/ExampleLength:
154137
Max: 32
155138

156-
# Offense count: 3
157-
# This cop supports safe autocorrection (--autocorrect).
158-
RSpec/ExcessiveDocstringSpacing:
159-
Exclude:
160-
- 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb'
161-
- 'spec/unit/puppet/type/mysql_user_spec.rb'
139+
# Offense count: 36
140+
# Configuration parameters: AllowSubject.
141+
RSpec/MultipleMemoizedHelpers:
142+
Max: 8
162143

163-
# Offense count: 131
164-
# This cop supports safe autocorrection (--autocorrect).
165-
# Configuration parameters: EnforcedStyle.
166-
# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
167-
RSpec/ImplicitSubject:
144+
# Offense count: 121
145+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
146+
# SupportedStyles: always, named_only
147+
RSpec/NamedSubject:
168148
Exclude:
169149
- 'spec/classes/graceful_failures_spec.rb'
170150
- 'spec/classes/mycnf_template_spec.rb'
@@ -176,14 +156,8 @@ RSpec/ImplicitSubject:
176156
- 'spec/classes/mysql_server_spec.rb'
177157
- 'spec/defines/mysql_db_spec.rb'
178158
- 'spec/functions/mysql_normalise_and_deepmerge_spec.rb'
179-
- 'spec/functions/mysql_password_spec.rb'
180159
- 'spec/functions/mysql_strip_hash_spec.rb'
181160

182-
# Offense count: 36
183-
# Configuration parameters: AllowSubject.
184-
RSpec/MultipleMemoizedHelpers:
185-
Max: 8
186-
187161
# Offense count: 45
188162
# Configuration parameters: AllowedGroups.
189163
RSpec/NestedGroups:
@@ -209,14 +183,6 @@ RSpec/StubbedMock:
209183
RSpec/VerifiedDoubleReference:
210184
EnforcedStyle: string
211185

212-
# Offense count: 2
213-
# This cop supports safe autocorrection (--autocorrect).
214-
# Configuration parameters: EnforcedStyle.
215-
# SupportedStyles: separated, grouped
216-
Style/AccessorGrouping:
217-
Exclude:
218-
- 'lib/puppet/provider/mysql_login_path/inifile.rb'
219-
220186
# Offense count: 3
221187
# This cop supports unsafe autocorrection (--autocorrect-all).
222188
# Configuration parameters: MinBranchesCount.

lib/puppet/provider/mysql_login_path/inifile.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ def parse(content)
416416
# object.
417417
class Parser
418418
attr_writer :section
419-
attr_accessor :property
420-
attr_accessor :value
419+
attr_accessor :property, :value
421420

422421
# Create a new IniFile::Parser that can be used to parse the contents of
423422
# an .ini file.

spec/acceptance/types/mysql_user_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class { 'mysql::server': * => $ed25519_opts }
136136
end
137137
end
138138
end
139+
139140
context 'using resource should throw no errors' do
140141
describe 'find users' do
141142
it do
@@ -145,6 +146,7 @@ class { 'mysql::server': * => $ed25519_opts }
145146
end
146147
end
147148
end
149+
148150
context 'using user-w-ssl@localhost with SSL' do
149151
describe 'adding user' do
150152
pp_five = <<-MANIFEST
@@ -172,6 +174,7 @@ class { 'mysql::server': * => $ed25519_opts }
172174
end
173175
end
174176
end
177+
175178
context 'using user-w-x509@localhost with X509' do
176179
describe 'adding user' do
177180
pp_six = <<-MANIFEST
@@ -199,6 +202,7 @@ class { 'mysql::server': * => $ed25519_opts }
199202
end
200203
end
201204
end
205+
202206
context 'using user-w-subject@localhost with ISSUER and SUBJECT' do
203207
describe 'adding user' do
204208
it 'works without errors' do

spec/classes/graceful_failures_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
end
1313

1414
it 'gracefully fails' do
15-
is_expected.to compile.and_raise_error(%r{Unsupported platform:})
15+
expect(subject).to compile.and_raise_error(%r{Unsupported platform:})
1616
end
1717
end
1818
end

spec/classes/mycnf_template_spec.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
let(:params) { { override_options: { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } } }
1414

1515
it do
16-
is_expected.to contain_file('mysql-config-file').with(mode: '0644',
17-
selinux_ignore_defaults: true).with_content(%r{socket = \/var\/lib\/mysql\/mysql.sock})
16+
expect(subject).to contain_file('mysql-config-file').with(mode: '0644',
17+
selinux_ignore_defaults: true).with_content(%r{socket = \/var\/lib\/mysql\/mysql.sock})
1818
end
1919
end
2020

2121
describe 'array entry' do
2222
let(:params) { { override_options: { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'] } } } }
2323

2424
it do
25-
is_expected.to contain_file('mysql-config-file').with_content(
25+
expect(subject).to contain_file('mysql-config-file').with_content(
2626
%r{.*replicate-do-db = base1\nreplicate-do-db = base2.*},
2727
)
2828
end
@@ -80,8 +80,8 @@
8080
let(:params) { { includedir: '/etc/my.cnf.d' } }
8181

8282
it 'makes the directory' do
83-
is_expected.to contain_file('/etc/my.cnf.d').with(ensure: :directory,
84-
mode: '0755')
83+
expect(subject).to contain_file('/etc/my.cnf.d').with(ensure: :directory,
84+
mode: '0755')
8585
end
8686

8787
it { is_expected.to contain_file('mysql-config-file').with_content(%r{!includedir}) }
@@ -91,8 +91,8 @@
9191
let(:params) { { includedir: '' } }
9292

9393
it 'shouldnt contain the directory' do
94-
is_expected.not_to contain_file('mysql-config-file').with(ensure: :directory,
95-
mode: '0755')
94+
expect(subject).not_to contain_file('mysql-config-file').with(ensure: :directory,
95+
mode: '0755')
9696
end
9797

9898
it { is_expected.to contain_file('mysql-config-file').without_content(%r{!includedir}) }
@@ -102,55 +102,55 @@
102102
let(:params) { { 'config_file_mode' => '0644' } }
103103

104104
it do
105-
is_expected.to contain_file('mysql-config-file').with(mode: '0644')
105+
expect(subject).to contain_file('mysql-config-file').with(mode: '0644')
106106
end
107107
end
108108

109109
context 'with file mode 0664' do
110110
let(:params) { { 'config_file_mode' => '0664' } }
111111

112112
it do
113-
is_expected.to contain_file('mysql-config-file').with(mode: '0664')
113+
expect(subject).to contain_file('mysql-config-file').with(mode: '0664')
114114
end
115115
end
116116

117117
context 'with file mode 0660' do
118118
let(:params) { { 'config_file_mode' => '0660' } }
119119

120120
it do
121-
is_expected.to contain_file('mysql-config-file').with(mode: '0660')
121+
expect(subject).to contain_file('mysql-config-file').with(mode: '0660')
122122
end
123123
end
124124

125125
context 'with file mode 0641' do
126126
let(:params) { { 'config_file_mode' => '0641' } }
127127

128128
it do
129-
is_expected.to contain_file('mysql-config-file').with(mode: '0641')
129+
expect(subject).to contain_file('mysql-config-file').with(mode: '0641')
130130
end
131131
end
132132

133133
context 'with file mode 0610' do
134134
let(:params) { { 'config_file_mode' => '0610' } }
135135

136136
it do
137-
is_expected.to contain_file('mysql-config-file').with(mode: '0610')
137+
expect(subject).to contain_file('mysql-config-file').with(mode: '0610')
138138
end
139139
end
140140

141141
context 'with file 0600' do
142142
let(:params) { { 'config_file_mode' => '0600' } }
143143

144144
it do
145-
is_expected.to contain_file('mysql-config-file').with(mode: '0600')
145+
expect(subject).to contain_file('mysql-config-file').with(mode: '0600')
146146
end
147147
end
148148

149149
context 'user owner 12345' do
150150
let(:params) { { 'mycnf_owner' => '12345' } }
151151

152152
it do
153-
is_expected.to contain_file('mysql-config-file').with(
153+
expect(subject).to contain_file('mysql-config-file').with(
154154
owner: '12345',
155155
)
156156
end
@@ -160,7 +160,7 @@
160160
let(:params) { { 'mycnf_group' => '12345' } }
161161

162162
it do
163-
is_expected.to contain_file('mysql-config-file').with(
163+
expect(subject).to contain_file('mysql-config-file').with(
164164
group: '12345',
165165
)
166166
end
@@ -170,7 +170,7 @@
170170
let(:params) { { 'mycnf_owner' => '12345', 'mycnf_group' => '12345' } }
171171

172172
it do
173-
is_expected.to contain_file('mysql-config-file').with(
173+
expect(subject).to contain_file('mysql-config-file').with(
174174
owner: '12345',
175175
group: '12345',
176176
)

spec/classes/mysql_backup_mysqldump_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class { 'mysql::server': }
3030
end
3131

3232
it {
33-
is_expected.to contain_cron('mysql-backup').with(
33+
expect(subject).to contain_cron('mysql-backup').with(
3434
hour: 23,
3535
minute: 59,
3636
monthday: 30,
@@ -44,7 +44,7 @@ class { 'mysql::server': }
4444
let(:params) { default_params }
4545

4646
it {
47-
is_expected.to contain_cron('mysql-backup').with(
47+
expect(subject).to contain_cron('mysql-backup').with(
4848
command: '/usr/local/sbin/mysqlbackup.sh',
4949
ensure: 'present',
5050
hour: 23,
@@ -62,13 +62,13 @@ class { 'mysql::server': }
6262
end
6363

6464
it {
65-
is_expected.to contain_file('mysqlbackup.sh').with_content(
65+
expect(subject).to contain_file('mysqlbackup.sh').with_content(
6666
%r{(\| TEST -TEST)},
6767
)
68-
is_expected.to contain_file('mysqlbackup.sh').with_content(
68+
expect(subject).to contain_file('mysqlbackup.sh').with_content(
6969
%r{(\.TEST)},
7070
)
71-
is_expected.not_to contain_package('bzip2')
71+
expect(subject).not_to contain_package('bzip2')
7272
}
7373
end
7474

@@ -81,7 +81,7 @@ class { 'mysql::server': }
8181
end
8282

8383
it {
84-
is_expected.to contain_file('mysqlbackup.sh').with_content(
84+
expect(subject).to contain_file('mysqlbackup.sh').with_content(
8585
%r{information_schema},
8686
)
8787
}

0 commit comments

Comments
 (0)