Skip to content

Commit d4e6d00

Browse files
author
Johan De Wit
committed
[Rubocop] Fixes
1 parent dd1e477 commit d4e6d00

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

lib/puppet/provider/mongodb.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,4 @@ def self.mongo_version
233233
def mongo_version
234234
self.class.mongo_version
235235
end
236-
237236
end

lib/puppet/provider/mongodb_replset/mongo.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def self.replset_properties
144144
end
145145
nil
146146
rescue Puppet::ExecutionFailure => e
147-
#if e.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command} || e.message =~ %r{no replset config has been received}
148147
if e.message =~ %r{command replSetGetConfig requires authentication} || e.message =~ %r{not authorized on admin to execute command}
149148
output = mongo_command('rs.status()', conn_string)
150149
if output['members']
@@ -188,9 +187,9 @@ def get_hosts_status(members)
188187
case e.message
189188
when %r{no replset config has been received}
190189
Puppet.warning('No replicaset config received, needs initialisation')
191-
when /Authentication failed/, /not authorized on admin/, /Authentication failed/
190+
when %r{Authentication failed}, %r{not authorized on admin}
192191
Puppet.warning "Host #{host} is available, but you are unauthorized because of authentication is enabled: #{auth_enabled}"
193-
when /command replSetGetStatus requires authentication/
192+
when %r{command replSetGetStatus requires authentication}
194193
Puppet.warning("Node #{host} is reachable but requires authentication: ReplicaSet not initialized")
195194
end
196195
alive.push(member)
@@ -410,11 +409,9 @@ def mongo_command(command, host, retries = 4)
410409

411410
def self.mongo_command(command, host = nil, retries = 4)
412411
output = mongo_eval("EJSON.stringify(#{command})", 'admin', retries, host)
413-
if output =~ %r{no replset config has been received} || output =~ %r{Authentication failed}
414-
output = '{}'
415-
end
416412

417413
# Hack to avoid non-json empty sets
414+
output = '{}' if output =~ %r{no replset config has been received} || output =~ %r{Authentication failed}
418415
output = '{}' if output == "null\n"
419416
output = '{}' if output == "\nnull\n"
420417

lib/puppet/provider/mongodb_user/mongodb.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def self.instances
2222
users.map do |user|
2323
db = if user['db'] == '$external'
2424
# For external users, we need to retreive the original DB name from here.
25-
user['customData']['createdBy'][/.*on db (.*)'\]$/,1]
25+
user['customData']['createdBy'][%r{.*on db (.*)'\]$}, 1]
2626
else
2727
user['db']
2828
end
@@ -120,7 +120,7 @@ def password_hash=(_value)
120120
end
121121
end
122122

123-
def password=(value)
123+
def password=(_value)
124124
command = {
125125
updateUser: @resource[:username],
126126
pwd: @resource[:password],

spec/unit/puppet/provider/mongodb_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
'x.x.x' => { '4' => false, '5' => false, '6' => false }
2121
}
2222

23-
v.each do |key, results|
23+
v.each do |key, _results|
2424
it "version detection for [#{key}]" do
2525
allow(provider_class).to receive(:mongo_eval).with('db.version()').and_return(key)
2626
end

0 commit comments

Comments
 (0)