Skip to content

Commit ad4b749

Browse files
committed
Rubocop fixes
This commit addresses Rubocop offenses from: - Performance/StringInclude - Style/TernaryParentheses
1 parent 61b5a74 commit ad4b749

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

acceptance/helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def wait_for_installation_pid(host)
334334
return
335335
end
336336

337-
unless %r{windows}.match?(host['platform'])
337+
unless host['platform'].include?('windows')
338338
step '(Agent) waiting for upgrade pid file to be created...' do
339339
retry_on(host, "cat #{upgrade_pidfile}", { max_retries: 5, retry_interval: 2 })
340340
end
@@ -355,7 +355,7 @@ def remove_installed_agent(host)
355355
end
356356

357357
step "Teardown: (Agent) Uninstall the puppet-agent package on agent #{host_to_info_s(host)}" do
358-
if %r{windows}.match?(host['platform'])
358+
if host['platform'].include?('windows')
359359
install_dir = on(host, 'facter.bat env_windows_installdir').output.tr('\\', '/').chomp
360360
scp_to(host, "#{SUPPORTING_FILES}/uninstall.ps1", 'uninstall.ps1')
361361
on(host, 'rm -rf C:/ProgramData/PuppetLabs')

spec/classes/puppet_agent_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def redhat_familly_supported_os
2626

2727
def global_facts(facts, os)
2828
facts.merge(
29-
if %r{sles}.match?(os)
29+
if os.include?('sles')
3030
{
3131
is_pe: true,
3232
env_temp_variable: '/tmp',
@@ -36,17 +36,17 @@ def global_facts(facts, os)
3636
{
3737
env_temp_variable: '/tmp',
3838
}
39-
elsif %r{solaris}.match?(os)
39+
elsif os.include?('solaris')
4040
{
4141
is_pe: true,
4242
puppet_agent_pid: 298,
4343
}
44-
elsif %r{aix}.match?(os)
44+
elsif os.include?('aix')
4545
{
4646
is_pe: true,
4747
platform_tag: "aix-#{AIX_VERSION[facts.dig(:os, 'release', 'major')]}-power",
4848
}
49-
elsif %r{windows}.match?(os)
49+
elsif os.include?('windows')
5050
{
5151
puppet_agent_appdata: 'C:\\ProgramData',
5252
puppet_confdir: 'C:\\ProgramData\\Puppetlabs\\puppet\\etc',
@@ -291,7 +291,7 @@ def global_facts(facts, os)
291291
end
292292

293293
let(:expected_package_install_options) do
294-
if %r{aix}.match?(os)
294+
if os.include?('aix')
295295
['--ignoreos', 'OPTION1=value1', 'OPTION2=value2']
296296
else
297297
['OPTION1=value1', 'OPTION2=value2']
@@ -307,7 +307,7 @@ def global_facts(facts, os)
307307
it { is_expected.to contain_package('puppet-agent') .with_install_options(expected_package_install_options) }
308308
end
309309

310-
if %r{solaris-10}.match?(os)
310+
if os.include?('solaris-10')
311311
it do
312312
is_expected.to contain_exec('solaris_install script')
313313
.with_command(
@@ -349,7 +349,7 @@ def global_facts(facts, os)
349349
it { is_expected.to contain_package('puppet-agent').with_ensure(package_version) }
350350
end
351351

352-
unless %r{windows}.match?(os)
352+
unless os.include?('windows')
353353
unless %r{sles|solaris|aix}.match?(os)
354354
it { is_expected.to contain_class('puppet_agent::service').that_requires('Class[puppet_agent::configure]') }
355355
end

spec/spec_helper_acceptance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def teardown_puppet_on(host)
130130
clean_repo = ''
131131
end
132132

133-
if %r{windows}.match?(host['platform'])
133+
if host['platform'].include?('windows')
134134
install_dir = on(host, 'facter.bat env_windows_installdir').output.tr('\\', '/').chomp
135135
scp_to host, "#{TEST_FILES}/uninstall.ps1", 'uninstall.ps1'
136136
on host, 'rm -rf C:/ProgramData/PuppetLabs'

task_spec/spec/acceptance/init_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def bolt_config
1919
def bolt_inventory
2020
host_data = hosts_to_inventory
2121
host_data['targets'].each do |node_data|
22-
node_data['config']['winrm']['connect-timeout'] = 120 if %r{win}.match?(target_platform)
22+
node_data['config']['winrm']['connect-timeout'] = 120 if target_platform.include?('win')
2323
end
2424

2525
host_data
@@ -97,7 +97,7 @@ def log_output_errors(result)
9797

9898
# extra request is needed on windows hosts
9999
# this will fail with "execution expired"
100-
run_task('puppet_agent::version', 'target', {}) if %r{win}.match?(target_platform)
100+
run_task('puppet_agent::version', 'target', {}) if target_platform.include?('win')
101101

102102
# Test the agent isn't already installed and that the version task works
103103
results = run_task('puppet_agent::version', 'target', {})
@@ -131,7 +131,7 @@ def log_output_errors(result)
131131
end
132132

133133
# Check that puppet agent service has been stopped due to 'stop_service' parameter set to true
134-
service = if %r{win}.match?(target_platform)
134+
service = if target_platform.include?('win')
135135
run_command('c:/"program files"/"puppet labs"/puppet/bin/puppet resource service puppet', 'target')
136136
else
137137
run_command('/opt/puppetlabs/bin/puppet resource service puppet', 'target')
@@ -190,7 +190,7 @@ def log_output_errors(result)
190190
end
191191

192192
# Puppet Agent can't be upgraded on Windows nodes while 'puppet agent' service or 'pxp-agent' service are running
193-
if %r{win}.match?(target_platform)
193+
if target_platform.include?('win')
194194
# Try to upgrade from puppet6 to puppet7 but fail due to puppet agent service already running
195195
results = run_task('puppet_agent::install', 'target', { 'collection' => 'puppet7', 'version' => 'latest' })
196196
results.each do |res|

tasks/facts_diff.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run
4949
run_result = Puppet::Util::Execution.execute(command, options)
5050

5151
minified_run_result = run_result.delete("\n").delete(' ')
52-
minified_run_result == '{}' ? 'No differences found' : run_result
52+
(minified_run_result == '{}') ? 'No differences found' : run_result
5353
end
5454

5555
private

tasks/run.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ def config_print(*keys)
138138
end
139139

140140
def noop(params)
141-
params['noop'] == true ? '--noop' : ''
141+
(params['noop'] == true) ? '--noop' : ''
142142
end
143143

144144
def environment(params)
145-
params['environment'].length > 1 ? "--environment=#{params['environment']}" : ''
145+
(params['environment'].length > 1) ? "--environment=#{params['environment']}" : ''
146146
end
147147

148148
# Attempts to run the Puppet agent, returning the mtime for the last run report

0 commit comments

Comments
 (0)