Skip to content

Commit 934c617

Browse files
renovate[bot]silugclaude
authored
Update dependency rubocop to '~> 1.87.0' (#332)
* Update dependency rubocop to '~> 1.87.0' * Fix rubocop 1.87 Style/FileOpen, OneClassPerFile, and parens offenses * Bump version --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Steven Pritchard <steve@sicura.us> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 62b5a72 commit 934c617

16 files changed

Lines changed: 167 additions & 164 deletions

File tree

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Layout/FirstArgumentIndentation:
150150
Layout/HashAlignment:
151151
Enabled: false
152152
Layout/HeredocIndentation:
153-
Enabled: false
153+
Enabled: true
154154
Layout/LeadingEmptyLines:
155155
Enabled: false
156156
Layout/SpaceAroundMethodCallOperator:

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Sun Jun 07 2026 Steven Pritchard <steve@sicura.us> - 5.0.2
2+
- Additional cleanup for rubocop
3+
14
* Wed Jan 07 2026 Steven Pritchard <steve@sicura.us> - 5.0.1
25
- Fix for CVE-2016-2183 in FIPS mode (#334)
36

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ gem_sources.each { |gem_source| source gem_source }
1313
group :syntax do
1414
gem 'metadata-json-lint'
1515
gem 'puppet-lint-trailing_comma-check', require: false
16-
gem 'rubocop', '~> 1.81.0'
16+
gem 'rubocop', '~> 1.87.0'
1717
gem 'rubocop-performance', '~> 1.26.0'
1818
gem 'rubocop-rake', '~> 0.7.0'
1919
gem 'rubocop-rspec', '~> 3.7.0'

lib/puppet/functions/simplib/passgen/legacy/passgen.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ def get_last_password(identifier, options, settings)
293293
if File.exist?(toread)
294294
passwd = IO.readlines(toread)[0].to_s.chomp
295295
sf = "#{File.dirname(toread)}/#{File.basename(toread, '.last')}.salt.last"
296-
saltfile = File.open(sf, 'a+', 0o640)
297-
if saltfile.stat.size.zero? # rubocop:disable Style/ZeroLengthPredicate
298-
salt = if options.key?('salt')
299-
options['salt']
300-
else
301-
gen_salt(options)
302-
end
303-
saltfile.puts(salt)
304-
saltfile.close
296+
File.open(sf, 'a+', 0o640) do |saltfile|
297+
if saltfile.stat.size.zero? # rubocop:disable Style/ZeroLengthPredicate
298+
salt = if options.key?('salt')
299+
options['salt']
300+
else
301+
gen_salt(options)
302+
end
303+
saltfile.puts(salt)
304+
end
305305
end
306306
salt = IO.readlines(sf)[0].to_s.chomp
307307
else

lib/puppet/functions/simplib/rand_cron.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def rand_cron(modifier, algorithm, occurs = 1, max_value = 59)
115115
[base]
116116
else
117117
(1..occurs).map do |i|
118-
((base - (modulus / occurs * i)) % modulus)
118+
(base - (modulus / occurs * i)) % modulus
119119
end
120120
end
121121
values.sort

lib/puppet/provider/prepend_file_line/ruby.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ def create
1313
tmpfile = "#{File.dirname(resource[:path])}/.~puppet_#{File.basename(resource[:path])}"
1414
begin
1515
File.exist?(tmpfile) and File.unlink(tmpfile)
16-
tmp_fh = File.open(tmpfile, 'w')
17-
18-
tmp_fh.puts(resource[:line])
19-
orig_fh = File.open(resource[:path], 'r')
20-
orig_fh.each_line do |ln|
21-
tmp_fh.puts(ln)
16+
File.open(tmpfile, 'w') do |tmp_fh|
17+
tmp_fh.puts(resource[:line])
18+
File.open(resource[:path], 'r') do |orig_fh|
19+
orig_fh.each_line do |ln|
20+
tmp_fh.puts(ln)
21+
end
22+
end
2223
end
23-
orig_fh.close
24-
tmp_fh.close
2524

2625
FileUtils.mv(tmpfile, resource[:path])
2726
rescue

lib/puppet/provider/runlevel/telinit.rb

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ def persist
2929
retval = :false
3030

3131
if @resource[:persist] == :true
32-
inittab = File.open('/etc/inittab', 'r')
33-
inittab.each_line do |line|
34-
next unless %r{^\s*id}.match?(line)
35-
# We have the initdefault line
36-
current_value = line.split(':').at(1)
37-
if current_value.eql?(@resource[:name])
38-
retval = :true
32+
File.open('/etc/inittab', 'r') do |inittab|
33+
inittab.each_line do |line|
34+
next unless %r{^\s*id}.match?(line)
35+
# We have the initdefault line
36+
current_value = line.split(':').at(1)
37+
if current_value.eql?(@resource[:name])
38+
retval = :true
39+
end
3940
end
4041
end
41-
inittab.close
4242
end
4343

4444
retval
@@ -47,29 +47,27 @@ def persist
4747
def persist=(_should)
4848
# Essentially do the same as the read, but save contents to new file
4949
newfile = ''
50-
inittab = File.open('/etc/inittab', 'r')
51-
5250
found_line = false
5351

54-
inittab.each_line do |line|
55-
if %r{^\s*id}.match?(line)
56-
# We've found the default line, so rewrite
57-
found_line = true
58-
newfile << "id:#{@resource[:name]}:initdefault:nil\n"
59-
else
60-
# Just add this line as is
61-
newfile << line
52+
File.open('/etc/inittab', 'r') do |inittab|
53+
inittab.each_line do |line|
54+
if %r{^\s*id}.match?(line)
55+
# We've found the default line, so rewrite
56+
found_line = true
57+
newfile << "id:#{@resource[:name]}:initdefault:nil\n"
58+
else
59+
# Just add this line as is
60+
newfile << line
61+
end
6262
end
6363
end
6464

6565
unless found_line
6666
newfile << "id:#{@resource[:name]}:initdefault:nil\n"
6767
end
6868

69-
inittab.close
70-
71-
inittab = File.open('/etc/inittab', 'w')
72-
inittab.write(newfile)
73-
inittab.close
69+
File.open('/etc/inittab', 'w') do |inittab|
70+
inittab.write(newfile)
71+
end
7472
end
7573
end

lib/puppet/provider/script_umask/ruby.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ def umask
1010
end
1111

1212
umasks = []
13-
fh = File.open(@resource[:name], 'r')
14-
fh.each_line do |line|
15-
next if %r{\s*#}.match?(line)
13+
File.open(@resource[:name], 'r') do |fh|
14+
fh.each_line do |line|
15+
next if %r{\s*#}.match?(line)
1616

17-
if line =~ %r{^\s*umask\s+(\d{3,4})}
18-
umasks << Regexp.last_match(1)
17+
if line =~ %r{^\s*umask\s+(\d{3,4})}
18+
umasks << Regexp.last_match(1)
19+
end
1920
end
2021
end
21-
fh.close
2222

2323
# Doing this so that, if multiple different umasks are found, we still get
2424
# the proper match.

lib/puppet/type/ftpusers.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ def sync
6060
tmpfile = "#{File.dirname(resource[:name])}/.~puppet_#{File.basename(resource[:name])}"
6161
begin
6262
File.exist?(tmpfile) and File.unlink(tmpfile)
63-
tmp_fh = File.open(tmpfile, 'w')
64-
65-
tmp_fh.puts('#FTP Users file autogenerated by Puppet')
66-
tmp_fh.puts((@should | @old_vals).join("\n"))
67-
tmp_fh.close
63+
File.open(tmpfile, 'w') do |tmp_fh|
64+
tmp_fh.puts('#FTP Users file autogenerated by Puppet')
65+
tmp_fh.puts((@should | @old_vals).join("\n"))
66+
end
6867

6968
FileUtils.mv(tmpfile, resource[:name])
7069
rescue => e

lib/puppetx/simp/simplib.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# PuppetX
22
module PuppetX; end
33
# PuppetX::SIMP
4-
module PuppetX::SIMP; end
4+
module PuppetX::SIMP; end # rubocop:disable Style/OneClassPerFile
55

66
# PuppetX::SIMP::Simplib
7-
module PuppetX::SIMP::Simplib
7+
module PuppetX::SIMP::Simplib # rubocop:disable Style/OneClassPerFile
88
# Sort a list of values based on usual human sorting semantics.
99
#
1010
# This regex taken from

0 commit comments

Comments
 (0)