Skip to content

Commit 0a16c95

Browse files
committed
(maint) Fix minor rubocop violations
1 parent 009e5bf commit 0a16c95

20 files changed

+562
-482
lines changed

server/.rubocop.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Metrics/PerceivedComplexity:
3333
Enabled: false
3434
Metrics/CyclomaticComplexity:
3535
Enabled: false
36-
36+
3737
# Empty method definitions over more than one line is ok
3838
Style/EmptyMethod:
3939
Enabled: false
@@ -59,3 +59,13 @@ Next:
5959
# Enforce LF line endings, even when on Windows
6060
Layout/EndOfLine:
6161
EnforcedStyle: lf
62+
63+
# We only alias for monkey patching
64+
Style/Alias:
65+
Enabled: false
66+
67+
# Harder to read when on
68+
Style/SymbolProc:
69+
Enabled: false
70+
Style/HashSyntax:
71+
Enabled: false

server/lib/debugserver/debug_protocol.rb

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def self.create(options)
3939
result = ProtocolMessage.create(options)
4040
raise('command is a required field for Request') if options['command'].nil?
4141

42-
result['command'] = options['command']
42+
result['command'] = options['command']
4343
result['arguments'] = options['arguments'] unless options['arguments'].nil?
4444

4545
result
@@ -60,7 +60,7 @@ def self.create(options = {})
6060
result = ProtocolMessage.create(options)
6161
raise('event is a required field for Event') if options['event'].nil?
6262

63-
result['event'] = options['event']
63+
result['event'] = options['event']
6464
result['body'] = options['body'] unless options['body'].nil?
6565

6666
result
@@ -83,8 +83,8 @@ def self.create(options = {})
8383
# }
8484
module Response
8585
def self.create_from_request(options, request = nil)
86-
result = ProtocolMessage.create({ 'seq' => -1, 'type' => 'response'})
87-
86+
result = ProtocolMessage.create('seq' => -1, 'type' => 'response')
87+
8888
raise('success is a required field for Response') if options['success'].nil?
8989

9090
result['request_seq'] = options['request_seq'] unless options['request_seq'].nil?
@@ -120,8 +120,8 @@ def self.create_from_request(options, request = nil)
120120
# // event: 'initialized';
121121
# }
122122
module InitializedEvent
123-
def self.create(options = {})
124-
result = Event.create({ 'event' => 'initialized', 'seq' => -1 })
123+
def self.create(_options = {})
124+
result = Event.create('event' => 'initialized', 'seq' => -1)
125125

126126
result
127127
end
@@ -153,7 +153,7 @@ def self.create(options = {})
153153
# }
154154
module StoppedEvent
155155
def self.create(options = {})
156-
result = Event.create({ 'event' => 'stopped', 'seq' => -1 })
156+
result = Event.create('event' => 'stopped', 'seq' => -1)
157157
raise('reason is a required field for StoppedEvent') if options['reason'].nil?
158158

159159
result['body'] = {}
@@ -177,7 +177,7 @@ def self.create(options)
177177
result = Request.create(options)
178178
raise('command is a required field for InitializeRequest') if options['command'].nil?
179179

180-
result['command'] = options['command']
180+
result['command'] = options['command']
181181
result['arguments'] = InitializeRequestArguments.create(options['arguments']) unless options['arguments'].nil?
182182

183183
result
@@ -232,7 +232,6 @@ def self.create_from_request(options, request = nil)
232232
end
233233
end
234234

235-
236235
# /** Event message for 'terminated' event types.
237236
# The event indicates that debugging of the debuggee has terminated.
238237
# */
@@ -247,7 +246,7 @@ def self.create_from_request(options, request = nil)
247246
# }
248247
module TerminatedEvent
249248
def self.create(options = {})
250-
result = Event.create({ 'event' => 'terminated', 'seq' => -1 })
249+
result = Event.create('event' => 'terminated', 'seq' => -1)
251250
result['body'] = {}
252251
result['body']['restart'] = options['restart'] unless options['restart'].nil?
253252

@@ -269,14 +268,14 @@ def self.create(options = {})
269268
# }
270269
module ThreadEvent
271270
def self.create(options = {})
272-
result = Event.create({ 'event' => 'thread', 'seq' => -1 })
271+
result = Event.create('event' => 'thread', 'seq' => -1)
273272

274273
raise('reason is a required field for ThreadEvent') if options['reason'].nil?
275274
raise('threadId is a required field for ThreadEvent') if options['threadId'].nil?
276-
275+
277276
result['body'] = {
278277
'reason' => options['reason'],
279-
'threadId' => options['threadId'],
278+
'threadId' => options['threadId']
280279
}
281280

282281
result
@@ -301,7 +300,7 @@ def self.create(options = {})
301300
# }
302301
module OutputEvent
303302
def self.create(options = {})
304-
result = Event.create({ 'event' => 'output', 'seq' => -1 })
303+
result = Event.create('event' => 'output', 'seq' => -1)
305304
raise('output is a required field for OutputEvent') if options['output'].nil?
306305

307306
result['body'] = { 'category' => 'console' }
@@ -314,7 +313,6 @@ def self.create(options = {})
314313
end
315314
end
316315

317-
318316
# /** Event message for 'exited' event type.
319317
# The event indicates that the debuggee has exited.
320318
# */
@@ -327,7 +325,7 @@ def self.create(options = {})
327325
# }
328326
module ExitedEvent
329327
def self.create(options = {})
330-
result = Event.create({ 'event' => 'exited', 'seq' => -1 })
328+
result = Event.create('event' => 'exited', 'seq' => -1)
331329
raise('exitCode is a required field for ExitedEvent') if options['exitCode'].nil?
332330
result['body'] = {}
333331
result['body']['exitCode'] = options['exitCode']
@@ -336,7 +334,6 @@ def self.create(options = {})
336334
end
337335
end
338336

339-
340337
# /** Launch request; value of command field is 'launch'. */
341338
# export interface LaunchRequest extends Request {
342339
# // command: 'launch';
@@ -347,7 +344,7 @@ def self.create(options)
347344
result = Request.create(options)
348345
raise('command is a required field for InitializeRequest') if options['command'].nil?
349346

350-
result['command'] = options['command']
347+
result['command'] = options['command']
351348
result['arguments'] = LaunchRequestArguments.create(options['arguments']) unless options['arguments'].nil?
352349

353350
result
@@ -376,7 +373,6 @@ def self.create_from_request(options, request = nil)
376373
end
377374
end
378375

379-
380376
# /** SetBreakpoints request; value of command field is 'setBreakpoints'.
381377
# Sets multiple breakpoints for a single source and clears all previous breakpoints in that source.
382378
# To clear all breakpoint for a source, specify an empty array.
@@ -509,7 +505,7 @@ module NextArguments
509505
def self.create(options)
510506
raise('threadId is a required field for NextArguments') if options['threadId'].nil?
511507

512-
{'threadId' => options['threadId']}
508+
{ 'threadId' => options['threadId'] }
513509
end
514510
end
515511

@@ -558,7 +554,7 @@ module StepInArguments
558554
def self.create(options)
559555
raise('threadId is a required field for StepInArguments') if options['threadId'].nil?
560556

561-
result = {'threadId' => options['threadId']}
557+
result = { 'threadId' => options['threadId'] }
562558
result['targetId'] = options['targetId'] unless options['targetId'].nil?
563559

564560
result
@@ -622,7 +618,7 @@ module StepOutArguments
622618
def self.create(options)
623619
raise('threadId is a required field for StepOutArguments') if options['threadId'].nil?
624620

625-
{'threadId' => options['threadId']}
621+
{ 'threadId' => options['threadId'] }
626622
end
627623
end
628624

@@ -650,7 +646,7 @@ module StackTraceArguments
650646
def self.create(options)
651647
result = {
652648
'startFrame' => 0,
653-
'levels' => 0,
649+
'levels' => 0
654650
}
655651

656652
raise('threadId is a required field for StackTraceArguments') if options['threadId'].nil?
@@ -663,7 +659,7 @@ def self.create(options)
663659
result
664660
end
665661
end
666-
662+
667663
# /** Response to 'stackTrace' request. */
668664
# export interface StackTraceResponse extends Response {
669665
# body: {
@@ -683,7 +679,7 @@ def self.create_from_request(options, request = nil)
683679

684680
result['body'] = {
685681
'stackFrames' => options['stackFrames'],
686-
'totalFrames' => options['stackFrames'].count,
682+
'totalFrames' => options['stackFrames'].count
687683
}
688684

689685
result
@@ -718,7 +714,7 @@ def self.create(options)
718714
module ScopesArguments
719715
def self.create(options)
720716
raise('frameId is a required field for ScopesArguments') if options['frameId'].nil?
721-
717+
722718
result = {}
723719

724720
result['frameId'] = options['frameId']
@@ -741,7 +737,7 @@ def self.create_from_request(options, request = nil)
741737
raise('scopes is a required field for ScopesResponse') if options['scopes'].nil?
742738

743739
result['body'] = {
744-
'scopes' => options['scopes'],
740+
'scopes' => options['scopes']
745741
}
746742

747743
result
@@ -785,15 +781,15 @@ def self.create(options)
785781
module VariablesArguments
786782
def self.create(options)
787783
raise('variablesReference is a required field for VariablesArguments') if options['variablesReference'].nil?
788-
784+
789785
result = {}
790786

791787
result['variablesReference'] = options['variablesReference']
792-
result['filter'] = options['filter'] unless options['filter'].nil?
793-
result['start'] = options['start'] unless options['start'].nil?
794-
result['count'] = options['count'] unless options['count'].nil?
795-
result['format'] = options['format'] unless options['format'].nil?
796-
788+
result['filter'] = options['filter'] unless options['filter'].nil?
789+
result['start'] = options['start'] unless options['start'].nil?
790+
result['count'] = options['count'] unless options['count'].nil?
791+
result['format'] = options['format'] unless options['format'].nil?
792+
797793
result
798794
end
799795
end
@@ -812,7 +808,7 @@ def self.create_from_request(options, request = nil)
812808
raise('variables is a required field for VariablesResponse') if options['variables'].nil?
813809

814810
result['body'] = {
815-
'variables' => options['variables'],
811+
'variables' => options['variables']
816812
}
817813

818814
result
@@ -873,14 +869,14 @@ def self.create(options)
873869
module EvaluateArguments
874870
def self.create(options)
875871
raise('expression is a required field for EvaluateArguments') if options['expression'].nil?
876-
872+
877873
result = {}
878874

879875
result['expression'] = options['expression']
880876
result['frameId'] = options['frameId'] unless options['frameId'].nil?
881877
result['context'] = options['context'] unless options['context'].nil?
882878
result['format'] = options['format'] unless options['format'].nil?
883-
879+
884880
result
885881
end
886882
end
@@ -910,20 +906,19 @@ def self.create_from_request(options, request = nil)
910906

911907
raise('result is a required field for EvaluateResponse') if options['result'].nil?
912908
raise('variablesReference is a required field for EvaluateResponse') if options['variablesReference'].nil?
913-
909+
914910
result['body'] = {
915911
'result' => options['result'],
916-
'variablesReference' => options['variablesReference'],
912+
'variablesReference' => options['variablesReference']
917913
}
918914
result['body']['type'] = options['type'] unless options['type'].nil?
919915
result['body']['namedVariables'] = options['namedVariables'] unless options['namedVariables'].nil?
920916
result['body']['indexedVariables'] = options['indexedVariables'] unless options['indexedVariables'].nil?
921-
917+
922918
result
923919
end
924920
end
925921

926-
927922
# /** Information about the capabilities of a debug adapter. */
928923
# export interface Capabilities {
929924
# /** The debug adapter supports the configurationDoneRequest. */
@@ -1018,7 +1013,7 @@ def self.create_from_request(options, request = nil)
10181013
raise('breakpoints is a required field for SetBreakpointsResponse') if options['breakpoints'].nil?
10191014

10201015
result['body'] = {
1021-
'breakpoints' => options['breakpoints'],
1016+
'breakpoints' => options['breakpoints']
10221017
}
10231018

10241019
result
@@ -1157,11 +1152,11 @@ def self.create(options)
11571152
raise('variablesReference is a required field for Scope') if options['variablesReference'].nil?
11581153
raise('expensive is a required field for Scope') if options['expensive'].nil?
11591154

1160-
result['name'] = options['name']
1161-
result['variablesReference'] = options['variablesReference']
1162-
result['expensive'] = options['expensive']
1163-
1164-
['namedVariables', 'indexedVariables', 'source', 'line', 'column', 'endLine', 'endColumn'].each do |varname|
1155+
result['name'] = options['name']
1156+
result['variablesReference'] = options['variablesReference']
1157+
result['expensive'] = options['expensive']
1158+
1159+
%w[namedVariables indexedVariables source line column endLine endColumn].each do |varname|
11651160
result[varname] = options[varname] unless options[varname].nil?
11661161
end
11671162

@@ -1209,16 +1204,15 @@ def self.create(options)
12091204
result['name'] = options['name']
12101205
result['value'] = options['value']
12111206
result['variablesReference'] = options['variablesReference']
1212-
1213-
['type', 'kind', 'evaluateName', 'namedVariables', 'indexedVariables'].each do |varname|
1207+
1208+
%w[type kind evaluateName namedVariables indexedVariables'].each do |varname|
12141209
result[varname] = options[varname] unless options[varname].nil?
12151210
end
12161211

12171212
result
12181213
end
12191214
end
12201215

1221-
12221216
# /** Properties of a breakpoint passed to the setBreakpoints request. */
12231217
# export interface SourceBreakpoint {
12241218
# /** The source line of the breakpoint. */
@@ -1303,6 +1297,5 @@ def self.create(options)
13031297
result
13041298
end
13051299
end
1306-
13071300
end
13081301
end

server/lib/languageserver/puppet_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def self.create(options)
2222
result['functionsLoaded'] = options['functionsLoaded'] unless options['functionsLoaded'].nil?
2323
result['typesLoaded'] = options['typesLoaded'] unless options['typesLoaded'].nil?
2424
result['classesLoaded'] = options['classesLoaded'] unless options['classesLoaded'].nil?
25-
25+
2626
result['languageServerVersion'] = PuppetVSCode.version
2727

2828
result

server/lib/puppet-debugserver.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def self.parse(options)
2121
ipaddress: '127.0.0.1',
2222
stop_on_client_exit: true,
2323
connection_timeout: 10,
24-
debug: nil,
24+
debug: nil
2525
}
2626

2727
opt_parser = OptionParser.new do |opts|
@@ -60,11 +60,11 @@ def self.parse(options)
6060
end
6161

6262
def self.log_message(severity, message)
63-
PuppetVSCode::log_message(severity, message)
63+
PuppetVSCode.log_message(severity, message)
6464
end
6565

6666
def self.init_puppet(options)
67-
PuppetVSCode::init_logging(options)
67+
PuppetVSCode.init_logging(options)
6868
log_message(:info, "Debug Server is v#{PuppetVSCode.version}")
6969

7070
true

0 commit comments

Comments
 (0)