Skip to content

Commit 00255c7

Browse files
committed
(CONT-789) Rubocop Unsafe Autocorrect 1-3
- Performance/MapCompact - Performance/StringInclude - RSpec/BeEq & RSpec/BeNil
1 parent ce19fe0 commit 00255c7

File tree

6 files changed

+6
-27
lines changed

6 files changed

+6
-27
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,6 @@ Performance/CollectionLiteralInLoop:
9999
- 'spec/classes/mysql_server_backup_spec.rb'
100100
- 'spec/defines/mysql_db_spec.rb'
101101

102-
# Offense count: 1
103-
# This cop supports unsafe autocorrection (--autocorrect-all).
104-
Performance/MapCompact:
105-
Exclude:
106-
- 'lib/puppet/provider/mysql_login_path/mysql_login_path.rb'
107-
108-
# Offense count: 2
109-
# This cop supports unsafe autocorrection (--autocorrect-all).
110-
Performance/StringInclude:
111-
Exclude:
112-
- 'lib/puppet/provider/mysql_grant/mysql.rb'
113-
- 'lib/puppet/provider/mysql_login_path/mysql_login_path.rb'
114-
115-
# Offense count: 3
116-
# This cop supports unsafe autocorrection (--autocorrect-all).
117-
RSpec/BeEq:
118-
Exclude:
119-
- 'spec/functions/mysql_normalise_and_deepmerge_spec.rb'
120-
- 'spec/functions/mysql_password_spec.rb'
121-
- 'spec/functions/mysql_strip_hash_spec.rb'
122-
123102
# Offense count: 64
124103
# Configuration parameters: Prefixes, AllowedPatterns.
125104
# Prefixes: when, with, without

lib/puppet/provider/mysql_grant/mysql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def self.instances
1919
# Default root user created by mysql_install_db on a host with fqdn
2020
# of myhost.mydomain.my: root@myhost.mydomain.my, when MySQL is started
2121
# with --skip-name-resolve.
22-
next if %r{There is no such grant defined for user}.match?(e.inspect)
22+
next if e.inspect.include?('There is no such grant defined for user')
2323

2424
raise Puppet::Error, _('#mysql had an error -> %{inspect}') % { inspect: e.inspect }
2525
end

lib/puppet/provider/mysql_login_path/mysql_login_path.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_password(context, uid, name)
7979
result = ''
8080
output = my_print_defaults_cmd(context, uid, '-s', name)
8181
output.split("\n").each do |line|
82-
result = line.sub(%r{--password=}, '') if %r{--password}.match?(line)
82+
result = line.sub(%r{--password=}, '') if line.include?('--password')
8383
end
8484
result
8585
end
@@ -133,7 +133,7 @@ def list_login_paths(context, uid)
133133

134134
def get(context, name)
135135
result = []
136-
owner = name.empty? ? ['root'] : name.map { |item| item[:owner] }.compact.uniq
136+
owner = name.empty? ? ['root'] : name.filter_map { |item| item[:owner] }.uniq
137137
owner.each do |uid|
138138
login_paths = list_login_paths(context, uid)
139139
result += login_paths

spec/functions/mysql_normalise_and_deepmerge_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
describe 'mysql::normalise_and_deepmerge' do
66
it 'exists' do
7-
expect(subject).not_to eq(nil)
7+
expect(subject).not_to be_nil
88
end
99

1010
it 'throws error with no arguments' do

spec/functions/mysql_password_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
shared_examples 'mysql::password function' do
66
it 'exists' do
7-
expect(subject).not_to eq(nil)
7+
expect(subject).not_to be_nil
88
end
99

1010
it 'raises a ArgumentError if there is less than 1 arguments' do

spec/functions/mysql_strip_hash_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
describe 'mysql::strip_hash' do
66
it 'exists' do
7-
expect(subject).not_to eq(nil)
7+
expect(subject).not_to be_nil
88
end
99

1010
it 'raises a ArgumentError if there is less than 1 arguments' do

0 commit comments

Comments
 (0)