Skip to content

Commit efcc297

Browse files
committed
Fix remaining rubocop offences
1 parent 2acaa45 commit efcc297

23 files changed

+76
-90
lines changed

lib/facter/es_facts.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def self.run
122122
end
123123
end
124124
rescue StandardError
125+
# ignore
125126
end
126127
Facter.add(:elasticsearch) do
127128
setcode do

lib/puppet/provider/elastic_parsedfile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class Puppet::Provider::ElasticParsedFile < Puppet::Provider::ParsedFile
99
#
1010
# @return String
1111
def self.xpack_config(val)
12-
@default_target ||= "/etc/elasticsearch/#{val}"
12+
@xpack_config ||= "/etc/elasticsearch/#{val}"
1313
end
1414
end

lib/puppet/provider/elastic_rest.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ def query_string
2828
# Perform a REST API request against the indicated endpoint.
2929
#
3030
# @return Net::HTTPResponse
31-
def self.rest(http, \
32-
req, \
33-
validate_tls = true, \
34-
timeout = 10, \
35-
username = nil, \
36-
password = nil)
31+
def self.rest(http,
32+
req,
33+
timeout = 10,
34+
username = nil,
35+
password = nil,
36+
validate_tls: true)
3737

3838
if username && password
3939
req.basic_auth username, password
@@ -84,15 +84,15 @@ def self.format_uri(resource_path, property_flush = {})
8484
# @return Array
8585
# an array of Hashes representing the found API objects, whether they be
8686
# templates, pipelines, et cetera.
87-
def self.api_objects(protocol = 'http', \
88-
validate_tls = true, \
89-
host = 'localhost', \
90-
port = 9200, \
91-
timeout = 10, \
92-
username = nil, \
93-
password = nil, \
94-
ca_file = nil, \
95-
ca_path = nil)
87+
def self.api_objects(protocol = 'http',
88+
host = 'localhost',
89+
port = 9200,
90+
timeout = 10,
91+
username = nil,
92+
password = nil,
93+
ca_file = nil,
94+
ca_path = nil,
95+
validate_tls: true)
9696

9797
uri = URI("#{protocol}://#{host}:#{port}/#{format_uri(api_discovery_uri)}")
9898
http = Net::HTTP.new uri.host, uri.port
@@ -103,7 +103,7 @@ def self.api_objects(protocol = 'http', \
103103
http.send method, arg if arg && http.respond_to?(method)
104104
end
105105

106-
response = rest http, req, validate_tls, timeout, username, password
106+
response = rest http, req, timeout, username, password, validate_tls: validate_tls
107107

108108
results = []
109109

@@ -151,14 +151,14 @@ def self.prefetch(resources)
151151
p = resource.parameters
152152
[
153153
p[:protocol].value,
154-
p[:validate_tls].value,
155154
p[:host].value,
156155
p[:port].value,
157156
p[:timeout].value,
158157
(p.key?(:username) ? p[:username].value : nil),
159158
(p.key?(:password) ? p[:password].value : nil),
160159
(p.key?(:ca_file) ? p[:ca_file].value : nil),
161-
(p.key?(:ca_path) ? p[:ca_path].value : nil)
160+
(p.key?(:ca_path) ? p[:ca_path].value : nil),
161+
p[:validate_tls].value,
162162
]
163163
# Deduplicate identical settings, and fetch templates
164164
end.uniq
@@ -228,10 +228,10 @@ def flush
228228
response = self.class.rest(
229229
http,
230230
req,
231-
resource[:validate_tls],
232231
resource[:timeout],
233232
resource[:username],
234-
resource[:password]
233+
resource[:password],
234+
validate_tls: resource[:validate_tls]
235235
)
236236

237237
# Attempt to return useful error output
@@ -257,14 +257,14 @@ def flush
257257
end
258258
@property_hash = self.class.api_objects(
259259
resource[:protocol],
260-
resource[:validate_tls],
261260
resource[:host],
262261
resource[:port],
263262
resource[:timeout],
264263
resource[:username],
265264
resource[:password],
266265
resource[:ca_file],
267-
resource[:ca_path]
266+
resource[:ca_path],
267+
validate_tls: resource[:validate_tls]
268268
).find do |t|
269269
t[:name] == resource[:name]
270270
end

lib/puppet/type/elasticsearch_index.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
newproperty(:settings) do
2222
desc 'Structured settings for the index in hash form.'
2323

24-
def insync?(is)
25-
Puppet_X::Elastic.asymmetric_compare(should, is)
24+
def insync?(value)
25+
Puppet_X::Elastic.asymmetric_compare(should, value)
2626
end
2727

2828
munge do |value|

lib/puppet/type/elasticsearch_keystore.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
# The keystore utility can only retrieve a list of stored settings,
3232
# so here we only compare the existing settings (sorted) with the
3333
# desired settings' keys
34-
def insync?(is)
34+
def insync?(value)
3535
if resource[:purge]
36-
is.sort == @should.first.keys.sort
36+
value.sort == @should.first.keys.sort
3737
else
38-
(@should.first.keys - is).empty?
38+
(@should.first.keys - value).empty?
3939
end
4040
end
4141

lib/puppet/type/elasticsearch_license.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
newproperty(:content) do
2222
desc 'Structured hash for license content data.'
2323

24-
def insync?(is)
24+
def insync?(value)
2525
Puppet_X::Elastic.asymmetric_compare(
2626
should.transform_values { |v| v.is_a?(Hash) ? (v.reject { |s, _| s == 'signature' }) : v },
27-
is
27+
value
2828
)
2929
end
3030

lib/puppet/type/elasticsearch_template.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
)
6565
end
6666

67-
def insync?(is)
68-
Puppet_X::Elastic.deep_implode(is) == \
67+
def insync?(value)
68+
Puppet_X::Elastic.deep_implode(value) == \
6969
Puppet_X::Elastic.deep_implode(should)
7070
end
7171
end
@@ -113,4 +113,5 @@ def insync?(is)
113113
self[:content] = PSON.load(tmp.content)
114114
end
115115
end
116+
# rubocop:enable Style/SignalException
116117
end

lib/puppet/type/elasticsearch_user_roles.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
newproperty(:roles, array_matching: :all) do
1313
desc 'Array of roles that the user should belong to.'
14-
def insync?(is)
15-
is.sort == should.sort
14+
def insync?(value)
15+
value.sort == should.sort
1616
end
1717
end
1818

lib/puppet_x/elastic/plugin_parsing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.plugin_version(raw_name)
1717
end
1818

1919
# Attempt to guess at the plugin's final directory name
20-
def self.plugin_split(original_string, position, soft_fail = true)
20+
def self.plugin_split(original_string, position, soft_fail: true)
2121
# Try both colon (maven) and slash-delimited (github/elastic.co) names
2222
%w[/ :].each do |delimiter|
2323
parts = original_string.split(delimiter)

spec/classes/000_elasticsearch_init_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
config: { 'node.name' => 'foo' }
88
}
99

10+
# rubocop:disable RSpec/MultipleMemoizedHelpers
1011
on_supported_os.each do |os, facts|
1112
context "on #{os}" do
1213
case facts[:os]['family']
@@ -293,6 +294,7 @@
293294
end
294295
end
295296
end
297+
# rubocop:enable RSpec/MultipleMemoizedHelpers
296298

297299
on_supported_os(
298300
hardwaremodels: ['x86_64'],
@@ -465,14 +467,14 @@
465467
# This check helps catch dependency cycles.
466468
context 'create_resource' do
467469
# Helper for these tests
468-
def singular(s)
469-
case s
470+
def singular(string)
471+
case string
470472
when 'indices'
471473
'index'
472474
when 'snapshot_repositories'
473475
'snapshot_repository'
474476
else
475-
s[0..-2]
477+
string[0..-2]
476478
end
477479
end
478480

0 commit comments

Comments
 (0)