Skip to content

Commit c7c75b9

Browse files
committed
(RUBOCOP) Manual fixes and .rubocop_todo update
Fixed - Lint/CopDirectiveSyntax
1 parent 4c835bb commit c7c75b9

File tree

17 files changed

+42
-36
lines changed

17 files changed

+42
-36
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

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/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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ 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)

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

lib/puppet-languageserver-sidecar/puppet_strings_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def populate_from_yard_registry!(puppet_path)
109109

110110
def populate_from_sidecar_cache!(path, cache)
111111
cached_result = cache.load(path, PuppetLanguageServerSidecar::Cache::PUPPETSTRINGS_SECTION)
112-
unless cached_result.nil? # rubocop:disable Style/GuardClause Reads better this way
112+
unless cached_result.nil? # rubocop:disable Style/GuardClause -- Reads better this way
113113
begin
114114
obj = FileDocumentation.new.from_json!(cached_result)
115115
@cache[path] = obj
@@ -381,10 +381,10 @@ def from_json!(json_string)
381381
case key
382382
when 'path'
383383
# Simple deserialised object types
384-
self.instance_variable_set(:"@#{key}", obj[key]) # rubocop:disable Style/RedundantSelf Reads better this way
384+
self.instance_variable_set(:"@#{key}", obj[key]) # rubocop:disable Style/RedundantSelf -- Reads better this way
385385
else
386386
# Sidecar protocol list object types
387-
prop = self.instance_variable_get(:"@#{key}") # rubocop:disable Style/RedundantSelf Reads better this way
387+
prop = self.instance_variable_get(:"@#{key}") # rubocop:disable Style/RedundantSelf -- Reads better this way
388388

389389
obj[key].each do |child_hash|
390390
child = prop.child_type.new

lib/puppet-languageserver/manifest/completion_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def self.resolve(session_state, completion_item)
275275
snippet = "#{data['name']} { '${1:title}':\n"
276276
attr_names.each_index do |index|
277277
name = attr_names[index]
278-
value_text = (name == 'ensure') ? 'present' : 'value' # rubocop:disable Style/TernaryParentheses In this case it's easier to read.
278+
value_text = (name == 'ensure') ? 'present' : 'value' # rubocop:disable Style/TernaryParentheses -- In this case it's easier to read.
279279
snippet += "\t#{name.ljust(max_length, ' ')} => '${#{index + 2}:#{value_text}}'\n"
280280
end
281281
snippet += '}'

lib/puppet-languageserver/message_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(*_)
1313
@session_state = ClientSessionState.new(self)
1414
end
1515

16-
def session_state # rubocop:disable Style/TrivialAccessors During the refactor, this is fine.
16+
def session_state # rubocop:disable Style/TrivialAccessors -- During the refactor, this is fine.
1717
@session_state
1818
end
1919

0 commit comments

Comments
 (0)