Skip to content

Commit 07aff8e

Browse files
authored
Merge pull request #397 from puppetlabs/CAT-2453
(CAT-2453) Update rubocop to remove rexml dependency
2 parents 4438f40 + c7c75b9 commit 07aff8e

File tree

21 files changed

+50
-44
lines changed

21 files changed

+50
-44
lines changed

.rubocop_todo.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-04-09 15:40:01 UTC using RuboCop version 1.64.1.
3+
# on 2025-09-30 12:45:13 UTC using RuboCop version 1.73.2.
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
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 1
10-
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
10+
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
1111
Lint/DuplicateBranch:
1212
Exclude:
1313
- 'lib/puppet-languageserver-sidecar/puppet_helper.rb'
@@ -36,7 +36,13 @@ Lint/OrAssignmentToConstant:
3636
Exclude:
3737
- 'lib/puppet-languageserver/session_state/document_store.rb'
3838

39-
# Offense count: 169
39+
# Offense count: 2
40+
Lint/UselessConstantScoping:
41+
Exclude:
42+
- 'lib/puppet-languageserver/manifest/format_on_type_provider.rb'
43+
- 'lib/puppet-languageserver/sidecar_protocol.rb'
44+
45+
# Offense count: 168
4046
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
4147
Metrics/AbcSize:
4248
Max: 152
@@ -86,10 +92,11 @@ Naming/MemoizedInstanceVariableName:
8692
- 'lib/puppet-languageserver-sidecar/puppet_strings_monkey_patches.rb'
8793
- 'lib/puppet-languageserver/server_capabilities.rb'
8894

89-
# Offense count: 3
95+
# Offense count: 4
9096
# Configuration parameters: MinSize.
9197
Performance/CollectionLiteralInLoop:
9298
Exclude:
99+
- 'lib/puppet-languageserver-sidecar/puppet_helper.rb'
93100
- 'lib/puppet-languageserver/sidecar_protocol.rb'
94101

95102
# Offense count: 1
@@ -109,14 +116,13 @@ Security/IoMethods:
109116
Style/Documentation:
110117
Enabled: false
111118

112-
# Offense count: 4
119+
# Offense count: 3
113120
# This cop supports unsafe autocorrection (--autocorrect-all).
114121
# Configuration parameters: AllowedReceivers.
115122
# AllowedReceivers: Thread.current
116123
Style/HashEachMethods:
117124
Exclude:
118125
- 'lib/puppet-languageserver-sidecar/facter_helper.rb'
119-
- 'lib/puppet-languageserver-sidecar/puppet_modulepath_monkey_patches.rb'
120126
- 'lib/puppet-languageserver-sidecar/puppet_strings_helper.rb'
121127
- 'lib/puppet-languageserver/manifest/folding_provider.rb'
122128

@@ -211,7 +217,7 @@ Style/ZeroLengthPredicate:
211217

212218
# Offense count: 622
213219
# This cop supports safe autocorrection (--autocorrect).
214-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
220+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
215221
# URISchemes: http, https
216222
Layout/LineLength:
217223
Max: 1529

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ group :development do
1414
gem 'puppet-lint', '~> 4.0', :require => false
1515
gem 'puppetfile-resolver', '~> 0.6.2', :require => false
1616
gem 'yard', '~> 0.9.28', :require => false
17-
gem "rubocop", '~> 1.64.0', :require => false
18-
gem "rubocop-performance", '~> 1.16', :require => false
19-
gem "rubocop-rspec", '~> 3.0', :require => false
17+
gem "rubocop", '~> 1.73.0', :require => false
18+
gem "rubocop-performance", '~> 1.24.0', :require => false
19+
gem "rubocop-rspec", '~> 3.5.0', :require => false
2020
gem 'simplecov', :require => false
2121
gem 'simplecov-console', :require => false
2222
gem 'json', "< 2.8.0", :require => false

lib/puppet-debugserver/debug_session/flow_control.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def assert_flag(flag_name)
5656
@flags[flag_name] = true
5757
PuppetDebugServer.log_message(:debug, "Asserting flag #{flag_name} is true")
5858
# Any custom logic for when flags are asserted
59-
# rubocop:disable Style/MultipleComparison, Style/SoleNestedConditional This is faster and doesn't require creation of an array
59+
# rubocop:disable Style/MultipleComparison, Style/SoleNestedConditional -- This is faster and doesn't require creation of an array
6060
if flag_name == :client_completed_configuration || flag_name == :session_setup
6161
# If the client_completed_configuration and session_setup flag are asserted but the session isn't active yet
6262
# assert the flag start_puppet so puppet can start in the main thread.

lib/puppet-debugserver/debug_session/hook_handlers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def on_hook_log_message(args)
214214
level = msg.level.to_s.capitalize
215215

216216
category = 'stderr'
217-
category = 'stdout' if msg.level == :notice || msg.level == :info || msg.level == :debug
217+
category = 'stdout' if %i[notice info debug].include?(msg.level)
218218

219219
@debug_session.send_output_event(
220220
'category' => category,

lib/puppet-debugserver/hooks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_hook(event_name, hook_name)
8989
# @note Modifying the returned hash does not alter the hooks, use
9090
# `add_hook`/`delete_hook` for that.
9191
def get_hooks(event_name)
92-
(@hooks[event_name.to_s]).to_h
92+
@hooks[event_name.to_s].to_h
9393
end
9494

9595
# @param [Symbol] event_name The name of the event.

lib/puppet-debugserver/message_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def request_evaluate(_connection_id, request_message)
8181
request_message,
8282
'result' => debug_session.evaluate_string(obj.arguments), 'variablesReference' => 0
8383
)
84-
rescue => e # rubocop:disable Style/RescueStandardError Anything could be thrown here. Catch 'em all
84+
rescue => e # rubocop:disable Style/RescueStandardError -- Anything could be thrown here. Catch 'em all
8585
PuppetEditorServices::Protocol::DebugAdapterMessages.reply_error(
8686
request_message,
8787
e.to_s

lib/puppet-debugserver/puppet_debug_session.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PuppetDebugSession
3434
attr_reader :puppet_session_state
3535

3636
# Use to track the default instance of the debug session
37-
@@session_instance = nil # rubocop:disable Style/ClassVars This class method (not instance) should be inherited
37+
@@session_instance = nil # rubocop:disable Style/ClassVars -- This class method (not instance) should be inherited
3838

3939
VARIABLES_REFERENCE_TOP_SCOPE = 1
4040
ERROR_LOG_LEVELS = %i[warning err alert emerg crit].freeze
@@ -44,7 +44,7 @@ def self.instance
4444
# This can be called from any thread
4545
return @@session_instance unless @@session_instance.nil? # This class method (not instance) should be inherited
4646

47-
@@session_instance = PuppetDebugSession.new # rubocop:disable Style/ClassVars This class method (not instance) should be inherited
47+
@@session_instance = PuppetDebugSession.new # rubocop:disable Style/ClassVars -- This class method (not instance) should be inherited
4848
end
4949

5050
def initialize
@@ -258,7 +258,7 @@ def generate_variables_list(arguments)
258258
result = nil
259259

260260
# Check if this is the topscope
261-
if variables_reference == VARIABLES_REFERENCE_TOP_SCOPE # rubocop:disable Style/IfUnlessModifier Nicer to read like this
261+
if variables_reference == VARIABLES_REFERENCE_TOP_SCOPE # rubocop:disable Style/IfUnlessModifier -- Nicer to read like this
262262
result = variable_list_from_hash(puppet_session_state.actual.compiler.topscope.to_hash(false))
263263
end
264264
return result unless result.nil?

lib/puppet-debugserver/puppet_monkey_patches.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def evaluate(target, scope)
5757
result = original_evaluate(target, scope)
5858
PuppetDebugServer::PuppetDebugSession.instance.execute_hook(:hook_after_pops_evaluate, [self, target, scope])
5959
result
60-
rescue => e # rubocop:disable Style/RescueStandardError Any error could be thrown here
60+
rescue => e # rubocop:disable Style/RescueStandardError -- Any error could be thrown here
6161
# Emit non-Puppet related errors to the debug log. We shouldn't get any of these!
6262
PuppetDebugServer.log_message(:debug, "Error in Puppet::Pops::Evaluator::EvaluatorImpl.evaluate #{e}: #{e.backtrace}") unless e.is_a?(Puppet::Error)
6363
raise

lib/puppet-languageserver-sidecar/puppet_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def self.retrieve_via_puppet_strings(cache, options = {})
8585
return result if object_types.empty?
8686

8787
current_env = current_environment
88-
for_agent = options[:for_agent].nil? ? true : options[:for_agent]
88+
for_agent = options[:for_agent].nil? || options[:for_agent]
8989
Puppet::Pops::Loaders.new(current_env, for_agent)
9090

9191
finder = PuppetPathFinder.new(current_env, object_types)
@@ -95,19 +95,19 @@ def self.retrieve_via_puppet_strings(cache, options = {})
9595
file_doc = PuppetLanguageServerSidecar::PuppetStringsHelper.file_documentation(path, finder.puppet_path, cache)
9696
next if file_doc.nil?
9797

98-
if object_types.include?(:class) # rubocop:disable Style/IfUnlessModifier This reads better
98+
if object_types.include?(:class) # rubocop:disable Style/IfUnlessModifier -- This reads better
9999
file_doc.classes.each { |item| result.append!(item) }
100100
end
101-
if object_types.include?(:datatype) # rubocop:disable Style/IfUnlessModifier This reads better
101+
if object_types.include?(:datatype) # rubocop:disable Style/IfUnlessModifier -- This reads better
102102
file_doc.datatypes.each { |item| result.append!(item) }
103103
end
104-
if object_types.include?(:function) # rubocop:disable Style/IfUnlessModifier This reads better
104+
if object_types.include?(:function) # rubocop:disable Style/IfUnlessModifier -- This reads better
105105
file_doc.functions.each { |item| result.append!(item) }
106106
end
107107
next unless object_types.include?(:type)
108108

109109
file_doc.types.each do |item|
110-
result.append!(item) unless name == 'whit' || name == 'component'
110+
result.append!(item) unless %w[whit component].include?(name)
111111
finder.temp_file.unlink if item.key == 'file' && File.exist?(finder.temp_file.path) # Remove the temp_file.rb if it exists
112112
end
113113
end

lib/puppet-languageserver-sidecar/puppet_modulepath_monkey_patches.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class Puppet::Settings::EnvironmentConf
118118
def modulepath
119119
result = original_modulepath
120120

121-
if PuppetLanguageServerSidecar::Workspace.has_module_metadata? # rubocop:disable Style/IfUnlessModifier Nicer to read like this
121+
if PuppetLanguageServerSidecar::Workspace.has_module_metadata? # rubocop:disable Style/IfUnlessModifier -- Nicer to read like this
122122
result = result + File::PATH_SEPARATOR + PuppetLanguageServerSidecar::Workspace.root_path
123123
end
124124

0 commit comments

Comments
 (0)