Skip to content

Commit 21b282c

Browse files
committed
Rubocop fixes, update to rubocop todo
1 parent 6bb2d34 commit 21b282c

58 files changed

Lines changed: 248 additions & 289 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rubocop_todo.yml

Lines changed: 7 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2026-02-04 04:17:01 UTC using RuboCop version 1.81.7.
3+
# on 2026-02-04 09:34:48 UTC using RuboCop version 1.81.7.
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
@@ -12,20 +12,6 @@ Gemspec/RequiredRubyVersion:
1212
Exclude:
1313
- 'puppet_docs.gemspec'
1414

15-
# Offense count: 1
16-
# This cop supports unsafe autocorrection (--autocorrect-all).
17-
# Configuration parameters: RequireParenthesesForMethodChains.
18-
Lint/AmbiguousRange:
19-
Exclude:
20-
- 'lib/puppet_docs/auto_redirects.rb'
21-
22-
# Offense count: 1
23-
# This cop supports unsafe autocorrection (--autocorrect-all).
24-
# Configuration parameters: AllowSafeAssignment.
25-
Lint/AssignmentInCondition:
26-
Exclude:
27-
- 'source/_plugins/partial.rb'
28-
2915
# Offense count: 4
3016
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
3117
Lint/DuplicateBranch:
@@ -39,12 +25,6 @@ Lint/MixedRegexpCaptureTypes:
3925
Exclude:
4026
- 'source/_plugins/partial.rb'
4127

42-
# Offense count: 2
43-
# This cop supports unsafe autocorrection (--autocorrect-all).
44-
Lint/NonAtomicFileOperation:
45-
Exclude:
46-
- 'Rakefile'
47-
4828
# Offense count: 1
4929
# Configuration parameters: AllowComments, AllowNil.
5030
Lint/SuppressedException:
@@ -103,32 +83,6 @@ Performance/CollectionLiteralInLoop:
10383
- 'lib/puppet_references/puppet/type.rb'
10484
- 'lib/puppet_references/version_tables/data/pe.rb'
10585

106-
# Offense count: 1
107-
# This cop supports unsafe autocorrection (--autocorrect-all).
108-
# Configuration parameters: SafeMultiline.
109-
Performance/DeletePrefix:
110-
Exclude:
111-
- 'lib/puppet_docs/config.rb'
112-
113-
# Offense count: 1
114-
# This cop supports unsafe autocorrection (--autocorrect-all).
115-
Performance/Detect:
116-
Exclude:
117-
- 'source/_plugins/markdown_blocks.rb'
118-
119-
# Offense count: 2
120-
# This cop supports unsafe autocorrection (--autocorrect-all).
121-
Performance/MapCompact:
122-
Exclude:
123-
- 'lib/puppet_docs/config.rb'
124-
- 'lib/puppet_docs/versions.rb'
125-
126-
# Offense count: 1
127-
# This cop supports unsafe autocorrection (--autocorrect-all).
128-
Performance/StringInclude:
129-
Exclude:
130-
- 'lib/puppet_references/version_tables/data/pe.rb'
131-
13286
# Offense count: 11
13387
# This cop supports safe autocorrection (--autocorrect).
13488
Rake/Desc:
@@ -140,71 +94,22 @@ Rake/MethodDefinitionInTask:
14094
Exclude:
14195
- 'Rakefile'
14296

143-
# Offense count: 1
144-
# This cop supports unsafe autocorrection (--autocorrect-all).
145-
# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
146-
# SupportedStyles: nested, compact
147-
# SupportedStylesForClasses: ~, nested, compact
148-
# SupportedStylesForModules: ~, nested, compact
149-
Style/ClassAndModuleChildren:
150-
Exclude:
151-
- 'source/_plugins/sitemap_generator.rb'
152-
15397
# Offense count: 3
15498
Style/ClassVars:
15599
Exclude:
156100
- 'lib/puppet_references/puppet/strings.rb'
157101

158-
# Offense count: 1
159-
# This cop supports unsafe autocorrection (--autocorrect-all).
160-
Style/CombinableLoops:
161-
Exclude:
162-
- 'lib/puppet_docs/config.rb'
163-
164-
# Offense count: 1
165-
# This cop supports unsafe autocorrection (--autocorrect-all).
166-
Style/CommentedKeyword:
167-
Exclude:
168-
- 'lib/puppet_references/util.rb'
169-
170102
# Offense count: 43
171103
# Configuration parameters: AllowedConstants.
172104
Style/Documentation:
173105
Enabled: false
174106

175-
# Offense count: 57
176-
# This cop supports unsafe autocorrection (--autocorrect-all).
177-
# Configuration parameters: EnforcedStyle.
178-
# SupportedStyles: always, always_true, never
179-
Style/FrozenStringLiteralComment:
180-
Enabled: false
181-
182107
# Offense count: 5
183108
# Configuration parameters: AllowedVariables.
184109
Style/GlobalVars:
185110
Exclude:
186111
- 'util/bbedit_tools/Markdown_with_kramdown.rb'
187112

188-
# Offense count: 3
189-
# This cop supports unsafe autocorrection (--autocorrect-all).
190-
# Configuration parameters: AllowSplatArgument.
191-
Style/HashConversion:
192-
Exclude:
193-
- 'lib/puppet_references/version_tables/data/agent.rb'
194-
- 'lib/puppet_references/version_tables/data/pe.rb'
195-
196-
# Offense count: 1
197-
# This cop supports unsafe autocorrection (--autocorrect-all).
198-
Style/HashTransformKeys:
199-
Exclude:
200-
- 'lib/puppet_references/util.rb'
201-
202-
# Offense count: 1
203-
# This cop supports unsafe autocorrection (--autocorrect-all).
204-
Style/HashTransformValues:
205-
Exclude:
206-
- 'lib/puppet_docs/config.rb'
207-
208113
# Offense count: 8
209114
# This cop supports safe autocorrection (--autocorrect).
210115
Style/IfUnlessModifier:
@@ -215,21 +120,6 @@ Style/IfUnlessModifier:
215120
- 'lib/puppet_references/version_tables/data/agent.rb'
216121
- 'lib/puppet_references/version_tables/data/pe.rb'
217122

218-
# Offense count: 3
219-
# This cop supports unsafe autocorrection (--autocorrect-all).
220-
# Configuration parameters: InverseMethods, InverseBlocks.
221-
Style/InverseMethods:
222-
Exclude:
223-
- 'lib/puppet_docs/config.rb'
224-
- 'lib/puppet_references/puppet/man.rb'
225-
- 'source/_plugins/limited_preview_hook.rb'
226-
227-
# Offense count: 1
228-
# This cop supports unsafe autocorrection (--autocorrect-all).
229-
Style/MinMaxComparison:
230-
Exclude:
231-
- 'source/_plugins/sitemap_generator.rb'
232-
233123
# Offense count: 1
234124
Style/MixinUsage:
235125
Exclude:
@@ -255,57 +145,16 @@ Style/OptionalBooleanParameter:
255145
Exclude:
256146
- 'lib/puppet_references/puppet/strings.rb'
257147

258-
# Offense count: 1
259-
# This cop supports unsafe autocorrection (--autocorrect-all).
260-
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
261-
# SupportedStyles: compact, exploded
262-
Style/RaiseArgs:
263-
Exclude:
264-
- 'source/_plugins/partial.rb'
265-
266-
# Offense count: 2
267-
# This cop supports unsafe autocorrection (--autocorrect-all).
268-
Style/RedundantInterpolation:
269-
Exclude:
270-
- 'Rakefile'
271-
- 'lib/puppet_references/puppet/man.rb'
272-
273-
# Offense count: 1
274-
# This cop supports unsafe autocorrection (--autocorrect-all).
275-
Style/RedundantSort:
276-
Exclude:
277-
- 'lib/puppet_references/version_tables/data/agent.rb'
278-
279-
# Offense count: 1
280-
# This cop supports unsafe autocorrection (--autocorrect-all).
281-
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
282-
# AllowedMethods: present?, blank?, presence, try, try!
283-
Style/SafeNavigation:
284-
Exclude:
285-
- 'source/_plugins/partial.rb'
286-
287-
# Offense count: 3
288-
# This cop supports unsafe autocorrection (--autocorrect-all).
289-
Style/SlicingWithRange:
290-
Exclude:
291-
- 'lib/puppet_docs/auto_redirects.rb'
292-
- 'lib/puppet_references/repo.rb'
293-
- 'source/_plugins/partial.rb'
294-
295-
# Offense count: 1
296-
# This cop supports unsafe autocorrection (--autocorrect-all).
297-
# Configuration parameters: RequireEnglish.
298-
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
299-
Style/SpecialGlobalVars:
300-
EnforcedStyle: use_perl_names
301-
302-
# Offense count: 64
148+
# Offense count: 5
303149
# This cop supports unsafe autocorrection (--autocorrect-all).
304150
# Configuration parameters: Mode.
305151
Style/StringConcatenation:
306-
Enabled: false
152+
Exclude:
153+
- 'lib/puppet_references/puppet/functions.rb'
154+
- 'lib/puppet_references/puppet/type_strings.rb'
155+
- 'util/bbedit_tools/Markdown_with_kramdown.rb'
307156

308-
# Offense count: 45
157+
# Offense count: 41
309158
# This cop supports safe autocorrection (--autocorrect).
310159
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
311160
# URISchemes: http, https

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org/'
24
gemspec name: 'puppet_docs'
35

Rakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rubygems'
24
require 'bundler/setup'
35
require 'rake'
@@ -60,7 +62,7 @@ task :preview, :filename do |_t, args|
6062
end
6163

6264
# Make sure we have a stash_directory
63-
FileUtils.mkdir(STASH_DIR) unless File.exist?(STASH_DIR)
65+
FileUtils.mkdir_p(STASH_DIR)
6466

6567
# Directories and files we have to have for a good live preview
6668
required_dirs = ['_config.yml', '_includes', '_plugins', 'files', 'favicon.ico', '_layouts', 'images']
@@ -108,7 +110,7 @@ end
108110
desc 'Move all stashed directories back into the source directory, ready for site generation. '
109111
task :unpreview do
110112
puts "\n*** Putting back the stashed files, removing the preview directory."
111-
FileUtils.mv Dir.glob("#{STASH_DIR}/*"), "#{SOURCE_DIR}"
113+
FileUtils.mv Dir.glob("#{STASH_DIR}/*"), SOURCE_DIR.to_s
112114
FileUtils.rm_rf(PREVIEW_DIR)
113115
puts "\n*** Done.\n\n"
114116
end

config.ru

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'pathname'
24

35
module Rack
@@ -13,7 +15,7 @@ module Rack
1315
return @app.call(env) if stat.file?
1416

1517
if stat.directory?
16-
index = Pathname.new(path) + 'index.html'
18+
index = "#{Pathname.new(path)}index.html"
1719
return list_directory(path_info, path, script_name) unless index.readable?
1820

1921
env['PATH_INFO'] = env['PATH_INFO'].sub(%r{/?$}, '/index.html')
@@ -35,7 +37,7 @@ module Rack
3537
return @app.call(@env) if @stat.file?
3638

3739
if @stat.directory?
38-
index = Pathname.new(@path) + 'index.html'
40+
index = "#{Pathname.new(@path)}index.html"
3941
return list_directory(@path_info, @path, @script_name) unless index.readable?
4042

4143
@env['PATH_INFO'] = @env['PATH_INFO'].sub(%r{/?$}, '/index.html')
@@ -50,4 +52,4 @@ end
5052

5153
puts '>>> Serving at http://localhost:9292'
5254

53-
run Rack::DirectoryWithIndexes.new(Pathname.new(__FILE__).parent + 'output')
55+
run Rack::DirectoryWithIndexes.new("#{Pathname.new(__FILE__).parent}output")

config/deploy.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
set :application, 'docs.puppet.com'
24
set :repository, 'git://github.com/puppetlabs/puppet-docs.git'
35
set :user, 'docsdeploy'
@@ -33,7 +35,7 @@
3335
Rake::Task['check_build_version'].invoke
3436
puts "DEPLOYING TO: #{domain}"
3537

36-
stage_dir = deploy_to + '/stage'
38+
stage_dir = "#{deploy_to}/stage"
3739

3840
sh "rsync -crlpv --delete --force output/ #{domain}:#{stage_dir}/"
3941

lib/puppet_docs.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'pathname'
24

35
module PuppetDocs

lib/puppet_docs/auto_redirects.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'yaml'
24

35
module PuppetDocs
@@ -45,7 +47,7 @@ def self.generate(config, redirects_yaml)
4547
at_baseurl = config['document_version_index'][doc][at_version]
4648
at_index = config['document_version_order'][doc].index(at_baseurl)
4749
new_versions = [latest] + config['document_version_order'][doc][0..at_index]
48-
old_versions = config['document_version_order'][doc][at_index + 1..-1]
50+
old_versions = config['document_version_order'][doc][(at_index + 1)..]
4951

5052
generated_rewrites = if forward_only
5153
[
@@ -62,7 +64,7 @@ def self.generate(config, redirects_yaml)
6264
end
6365

6466
# Return a string ready to append to the nginx config file:
65-
redirect_lines.join("\n") + "\n"
67+
"#{redirect_lines.join("\n")}\n"
6668
end
6769

6870
# Normalize string-or-array into normal array, and strip leading ./ or /

0 commit comments

Comments
 (0)