Skip to content

Commit 995a1cd

Browse files
committed
rubocop: autofix
1 parent 74b8057 commit 995a1cd

File tree

26 files changed

+268
-251
lines changed

26 files changed

+268
-251
lines changed

.rubocop_todo.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
3-
# using RuboCop version 1.50.2.
3+
# using RuboCop version 1.85.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
@@ -15,6 +15,7 @@ Lint/MissingCopEnableDirective:
1515
- 'spec/unit/puppet/type/zabbix_host_spec.rb'
1616

1717
# Offense count: 1
18+
# Configuration parameters: AllowedParentClasses.
1819
Lint/MissingSuper:
1920
Exclude:
2021
- 'spec/serverspec_type_zabbixapi.rb'
@@ -33,11 +34,22 @@ RSpec/BeEq:
3334
- 'spec/acceptance/zabbix_proxy_spec.rb'
3435
- 'spec/unit/puppet/type/zabbix_template_spec.rb'
3536

36-
# Offense count: 1
37-
# This cop supports unsafe autocorrection (--autocorrect-all).
38-
RSpec/EmptyExampleGroup:
37+
# Offense count: 39
38+
RSpec/LeakyLocalVariable:
3939
Exclude:
40+
- 'spec/acceptance/zabbix_host_spec.rb'
41+
- 'spec/acceptance/zabbix_hostgroup_spec.rb'
42+
- 'spec/acceptance/zabbix_proxy_spec.rb'
43+
- 'spec/acceptance/zabbix_template_spec.rb'
4044
- 'spec/classes/agent_spec.rb'
45+
- 'spec/classes/database_mysql_spec.rb'
46+
- 'spec/classes/database_postgresql_spec.rb'
47+
- 'spec/classes/proxy_spec.rb'
48+
- 'spec/classes/repo_spec.rb'
49+
- 'spec/classes/sender_spec.rb'
50+
- 'spec/classes/server_spec.rb'
51+
- 'spec/defines/userparameters_spec.rb'
52+
- 'spec/unit/puppet/type/zabbix_template_spec.rb'
4153

4254
# Offense count: 4
4355
# Configuration parameters: .
@@ -50,6 +62,13 @@ RSpec/RepeatedExampleGroupDescription:
5062
Exclude:
5163
- 'spec/defines/startup_spec.rb'
5264

65+
# Offense count: 3
66+
RSpec/SpecFilePathSuffix:
67+
Exclude:
68+
- 'spec/unit/puppet/provider/zabbix_host/ruby.rb'
69+
- 'spec/unit/puppet/provider/zabbix_hostgroup/ruby.rb'
70+
- 'spec/unit/puppet/provider/zabbix_proxy/ruby.rb'
71+
5372
# Offense count: 4
5473
RSpec/StubbedMock:
5574
Exclude:

lib/puppet/provider/zabbix.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ def zbx
4747

4848
# Create the api connection
4949
def self.create_connection
50-
protocol = api_config['default']['apache_use_ssl'] == 'true' ? 'https' : 'http'
50+
protocol = (api_config['default']['apache_use_ssl'] == 'true') ? 'https' : 'http'
5151
ZabbixApi.connect(
5252
url: "#{protocol}://#{api_config['default']['zabbix_url']}/api_jsonrpc.php",
5353
user: api_config['default']['zabbix_user'],
5454
password: api_config['default']['zabbix_pass'],
5555
http_user: api_config['default']['zabbix_user'],
5656
http_password: api_config['default']['zabbix_pass'],
57-
ignore_version: true
57+
ignore_version: true,
5858
)
5959
end
6060

@@ -68,11 +68,11 @@ def check_host(host)
6868
method: 'host.get',
6969
params: {
7070
filter: {
71-
'host' => [host]
71+
'host' => [host],
7272
},
7373
selectParentTemplates: ['host'],
74-
output: ['host']
75-
}
74+
output: ['host'],
75+
},
7676
)
7777
rescue Puppet::ExecutionFailure
7878
false

lib/puppet/provider/zabbix_host/ruby.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def self.instances
1414
selectInterfaces: %w[interfaceid type main ip port useip details],
1515
selectGroups: ['name'],
1616
selectMacros: %w[macro value],
17-
output: %w[host proxy_hostid tls_accept tls_connect tls_issuer tls_subject]
18-
}
17+
output: %w[host proxy_hostid tls_accept tls_connect tls_issuer tls_subject],
18+
},
1919
)
2020

2121
api_hosts.map do |h|
@@ -43,7 +43,7 @@ def self.instances
4343
tls_accept: h['tls_accept'].to_i,
4444
tls_connect: h['tls_connect'].to_i,
4545
tls_issuer: h['tls_issuer'].to_s,
46-
tls_subject: h['tls_subject'].to_s
46+
tls_subject: h['tls_subject'].to_s,
4747
)
4848
end
4949
end
@@ -63,7 +63,7 @@ def create
6363
gids = get_groupids(@resource[:groups], @resource[:group_create])
6464
groups = transform_to_array_hash('groupid', gids)
6565

66-
proxy_hostid = @resource[:proxy].nil? || @resource[:proxy].empty? ? nil : zbx.proxies.get_id(host: @resource[:proxy])
66+
proxy_hostid = (@resource[:proxy].nil? || @resource[:proxy].empty?) ? nil : zbx.proxies.get_id(host: @resource[:proxy])
6767

6868
tls_accept = @resource[:tls_accept].nil? ? 1 : @resource[:tls_accept]
6969
tls_connect = @resource[:tls_connect].nil? ? 1 : @resource[:tls_connect]
@@ -80,15 +80,15 @@ def create
8080
dns: @resource[:hostname],
8181
port: @resource[:port],
8282
useip: @resource[:use_ip] ? 1 : 0,
83-
details: @resource[:interfacedetails].nil? ? {} : @resource[:interfacedetails]
84-
}
83+
details: @resource[:interfacedetails].nil? ? {} : @resource[:interfacedetails],
84+
},
8585
],
8686
templates: templates,
8787
groups: groups,
8888
tls_connect: tls_connect,
8989
tls_accept: tls_accept,
9090
tls_issuer: @resource[:tls_issuer].nil? ? '' : @resource[:tls_issuer],
91-
tls_subject: @resource[:tls_subject].nil? ? '' : @resource[:tls_subject]
91+
tls_subject: @resource[:tls_subject].nil? ? '' : @resource[:tls_subject],
9292
)
9393
end
9494

@@ -139,8 +139,8 @@ def ipaddress=(string)
139139
method: 'hostinterface.update',
140140
params: {
141141
interfaceid: @property_hash[:interfaceid],
142-
ip: string
143-
}
142+
ip: string,
143+
},
144144
)
145145
end
146146

@@ -150,8 +150,8 @@ def use_ip=(boolean)
150150
params: {
151151
interfaceid: @property_hash[:interfaceid],
152152
useip: boolean ? 1 : 0,
153-
dns: @resource[:hostname]
154-
}
153+
dns: @resource[:hostname],
154+
},
155155
)
156156
end
157157

@@ -160,8 +160,8 @@ def port=(int)
160160
method: 'hostinterface.update',
161161
params: {
162162
interfaceid: @property_hash[:interfaceid],
163-
port: int
164-
}
163+
port: int,
164+
},
165165
)
166166
end
167167

@@ -170,8 +170,8 @@ def interfacetype=(int)
170170
method: 'hostinterface.update',
171171
params: {
172172
interfaceid: @property_hash[:interfaceid],
173-
type: int
174-
}
173+
type: int,
174+
},
175175
)
176176
end
177177

@@ -180,8 +180,8 @@ def interfacedetails=(hash)
180180
method: 'hostinterface.update',
181181
params: {
182182
interfaceid: @property_hash[:interfaceid],
183-
details: hash
184-
}
183+
details: hash,
184+
},
185185
)
186186
end
187187

@@ -191,7 +191,7 @@ def groups=(hostgroups)
191191

192192
zbx.hosts.create_or_update(
193193
host: @resource[:hostname],
194-
groups: groups
194+
groups: groups,
195195
)
196196
end
197197

@@ -204,8 +204,8 @@ def templates=(array)
204204
params: {
205205
hostids: @property_hash[:id],
206206
selectParentTemplates: ['templateid'],
207-
output: ['host']
208-
}
207+
output: ['host'],
208+
},
209209
).first['parentTemplates'].map { |t| t['templateid'].to_i }
210210
templates_clear = is_template_ids - should_template_ids
211211

@@ -214,8 +214,8 @@ def templates=(array)
214214
params: {
215215
hostid: @property_hash[:id],
216216
templates: transform_to_array_hash('templateid', should_template_ids),
217-
templates_clear: transform_to_array_hash('templateid', templates_clear)
218-
}
217+
templates_clear: transform_to_array_hash('templateid', templates_clear),
218+
},
219219
)
220220
end
221221

@@ -225,23 +225,23 @@ def macros=(array)
225225
method: 'host.update',
226226
params: {
227227
hostid: @property_hash[:id],
228-
macros: macroarray
229-
}
228+
macros: macroarray,
229+
},
230230
)
231231
end
232232

233233
def proxy=(string)
234234
zbx.hosts.create_or_update(
235235
host: @resource[:hostname],
236-
proxy_hostid: zbx.proxies.get_id(host: string)
236+
proxy_hostid: zbx.proxies.get_id(host: string),
237237
)
238238
end
239239

240240
def tls_connect=(int)
241241
@property_hash[:tls_connect] = int
242242
zbx.hosts.create_or_update(
243243
host: @resource[:hostname],
244-
tls_connect: @property_hash[:tls_connect].nil? ? 1 : @property_hash[:tls_connect]
244+
tls_connect: @property_hash[:tls_connect].nil? ? 1 : @property_hash[:tls_connect],
245245
)
246246
end
247247

@@ -250,23 +250,23 @@ def tls_accept=(int)
250250

251251
zbx.hosts.create_or_update(
252252
host: @resource[:hostname],
253-
tls_accept: @property_hash[:tls_accept].nil? ? 1 : @property_hash[:tls_accept]
253+
tls_accept: @property_hash[:tls_accept].nil? ? 1 : @property_hash[:tls_accept],
254254
)
255255
end
256256

257257
def tls_issuer=(string)
258258
@property_hash[:tls_issuer] = string
259259
zbx.hosts.create_or_update(
260260
host: @resource[:hostname],
261-
tls_issuer: @property_hash[:tls_issuer].nil? ? '' : @property_hash[:tls_issuer]
261+
tls_issuer: @property_hash[:tls_issuer].nil? ? '' : @property_hash[:tls_issuer],
262262
)
263263
end
264264

265265
def tls_subject=(string)
266266
@property_hash[:tls_subject] = string
267267
zbx.hosts.create_or_update(
268268
host: @resource[:hostname],
269-
tls_subject: @property_hash[:tls_subject].nil? ? '' : @property_hash[:tls_subject]
269+
tls_subject: @property_hash[:tls_subject].nil? ? '' : @property_hash[:tls_subject],
270270
)
271271
end
272272
end

lib/puppet/provider/zabbix_hostgroup/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def self.instances
1010
api_hostgroups.map do |group_name, _id|
1111
new(
1212
ensure: :present,
13-
name: group_name
13+
name: group_name,
1414
)
1515
end
1616
end

0 commit comments

Comments
 (0)