Skip to content

Commit 0ea6f0d

Browse files
committed
bumping rubocop, safe autocorrection and new todo
1 parent 22a2744 commit 0ea6f0d

File tree

9 files changed

+28
-26
lines changed

9 files changed

+28
-26
lines changed

.rubocop_todo.yml

+18-10
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 2024-01-22 15:21:03 UTC using RuboCop version 1.50.2.
3+
# on 2025-04-09 10:54:46 UTC using RuboCop version 1.70.0.
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
@@ -14,7 +14,7 @@ Gemspec/RequireMFA:
1414
Exclude:
1515
- 'puppet-strings.gemspec'
1616

17-
# Offense count: 45
17+
# Offense count: 44
1818
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
1919
Metrics/AbcSize:
2020
Max: 95
@@ -25,17 +25,12 @@ Metrics/AbcSize:
2525
Metrics/BlockLength:
2626
Max: 44
2727

28-
# Offense count: 1
29-
# Configuration parameters: CountBlocks.
30-
Metrics/BlockNesting:
31-
Max: 4
32-
3328
# Offense count: 5
3429
# Configuration parameters: CountComments, CountAsOne.
3530
Metrics/ClassLength:
3631
Max: 283
3732

38-
# Offense count: 34
33+
# Offense count: 33
3934
# Configuration parameters: AllowedMethods, AllowedPatterns.
4035
Metrics/CyclomaticComplexity:
4136
Max: 36
@@ -68,6 +63,7 @@ Naming/AccessorMethodName:
6863
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
6964
Naming/FileName:
7065
Exclude:
66+
- 'Rakefile.rb'
7167
- 'lib/puppet-strings.rb'
7268

7369
# Offense count: 1
@@ -85,12 +81,14 @@ Naming/MethodParameterName:
8581
- 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb'
8682
- 'lib/puppet-strings/yard/parsers/puppet/parser.rb'
8783

88-
# Offense count: 2
84+
# Offense count: 4
8985
# Configuration parameters: MinSize.
9086
Performance/CollectionLiteralInLoop:
9187
Exclude:
88+
- 'lib/puppet-strings/yard/handlers/puppet/base.rb'
9289
- 'lib/puppet-strings/yard/handlers/ruby/provider_handler.rb'
9390
- 'lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb'
91+
- 'lib/puppet-strings/yard/util.rb'
9492

9593
# Offense count: 1
9694
RSpec/BeforeAfterAll:
@@ -123,7 +121,7 @@ RSpec/DescribeClass:
123121
- 'spec/acceptance/generate_markdown_spec.rb'
124122
- 'spec/acceptance/running_strings_generate_spec.rb'
125123

126-
# Offense count: 48
124+
# Offense count: 51
127125
# Configuration parameters: CountAsOne.
128126
RSpec/ExampleLength:
129127
Max: 66
@@ -159,6 +157,7 @@ Style/ClassVars:
159157
- 'lib/puppet-strings/yard/templates/default/layout/html/setup.rb'
160158

161159
# Offense count: 3
160+
# This cop supports unsafe autocorrection (--autocorrect-all).
162161
Style/CombinableLoops:
163162
Exclude:
164163
- 'lib/puppet-strings/markdown.rb'
@@ -187,3 +186,12 @@ Style/OptionalBooleanParameter:
187186
- 'lib/puppet-strings/yard/code_objects/type.rb'
188187
- 'lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb'
189188
- 'lib/puppet-strings/yard/handlers/ruby/function_handler.rb'
189+
190+
# Offense count: 2
191+
# This cop supports unsafe autocorrection (--autocorrect-all).
192+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
193+
# AllowedMethods: present?, blank?, presence, try, try!
194+
Style/SafeNavigation:
195+
Exclude:
196+
- 'lib/puppet-strings/yard/handlers/puppet/function_handler.rb'
197+
- 'lib/puppet-strings/yard/handlers/ruby/function_handler.rb'

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ group :development do
3636
gem 'rspec', '~> 3.1'
3737
gem 'rspec-its', '~> 1.0'
3838

39-
gem 'rubocop', '~> 1.64.0', require: false
39+
gem 'rubocop', '~> 1.70.0', require: false
4040
gem 'rubocop-performance', '~> 1.16', require: false
4141
gem 'rubocop-rspec', '~> 3.0', require: false
4242

lib/puppet-strings/yard/handlers/puppet/base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def set_parameter_types(object)
2121
tags.each do |tag|
2222
next if statement.parameters.find { |p| tag.name == p.name }
2323

24-
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless tag.name == 'name' || tag.name == 'title'
24+
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless %w[name title].include?(tag.name)
2525
end
2626

2727
# Assign the types for the parameter

lib/puppet-strings/yard/handlers/ruby/provider_handler.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def register_provider_docstring(object)
6161
# Look for a call to a dispatch method with a block
6262
next unless
6363
child.method_name &&
64-
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
64+
['desc', 'doc='].include?(child.method_name.source) &&
6565
child.parameters(false).count == 1
6666

6767
docstring = node_as_string(child.parameters[0])

lib/puppet-strings/yard/handlers/ruby/type_base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def find_docstring(node, kind)
3434
elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode)
3535
# Look for a call to a dispatch method with a block
3636
next unless child.method_name &&
37-
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
37+
['desc', 'doc='].include?(child.method_name.source) &&
3838
child.parameters(false).count == 1
3939

4040
docstring = node_as_string(child.parameters[0])

lib/puppet-strings/yard/parsers/puppet/statement.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def initialize(object, file)
170170
case type_expr
171171
when Puppet::Pops::Model::AccessExpression
172172
# TODO: I don't like rebuilding the source from the AST, but AccessExpressions don't expose the original source
173-
@alias_of = +"#{PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
173+
@alias_of = "#{PuppetStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
174174
@alias_of << type_expr.keys.map { |key| PuppetStrings::Yard::Util.ast_to_text(key) }.join(', ')
175175
@alias_of << ']'
176176
else

lib/puppet-strings/yard/templates/default/tags/setup.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
# @return [Array<YARD::Tag>] Returns the parameter tags if the object should have parameters.
55
def param
66
tag(:param) if
7-
object.type == :method ||
8-
object.type == :puppet_class ||
9-
object.type == :puppet_data_type ||
10-
object.type == :puppet_defined_type ||
11-
object.type == :puppet_function ||
12-
object.type == :puppet_task ||
13-
object.type == :puppet_plan
7+
%i[method puppet_class puppet_data_type puppet_defined_type puppet_function puppet_task puppet_plan].include?(object.type)
148
end
159

1610
# Renders the overload section.

lib/puppet-strings/yard/util.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def self.tags_to_hashes(tags)
4040

4141
tag = { tag_name: t.tag_name }
4242
# grab nested information for @option and @enum tags
43-
if tag[:tag_name] == 'option' || tag[:tag_name] == 'enum'
43+
if %w[option enum].include?(tag[:tag_name])
4444
tag[:opt_name] = t.pair.name
4545
tag[:opt_text] = t.pair.text
4646
tag[:opt_types] = t.pair.types if t.pair.types

puppet-strings.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
2222
]
2323
s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*']
2424

25-
s.add_runtime_dependency 'puppet', '>= 8.0.0'
26-
s.add_runtime_dependency 'rgen', '~> 0.9'
27-
s.add_runtime_dependency 'yard', '~> 0.9'
25+
s.add_dependency 'puppet', '>= 8.0.0'
26+
s.add_dependency 'rgen', '~> 0.9'
27+
s.add_dependency 'yard', '~> 0.9'
2828
end

0 commit comments

Comments
 (0)