Skip to content

Commit

Permalink
(maint) Fix minor rubocop violations
Browse files Browse the repository at this point in the history
  • Loading branch information
glennsarti committed Jan 9, 2018
1 parent 93fe628 commit bee03c1
Show file tree
Hide file tree
Showing 20 changed files with 562 additions and 482 deletions.
12 changes: 11 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Metrics/PerceivedComplexity:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false

# Empty method definitions over more than one line is ok
Style/EmptyMethod:
Enabled: false
Expand All @@ -59,3 +59,13 @@ Next:
# Enforce LF line endings, even when on Windows
Layout/EndOfLine:
EnforcedStyle: lf

# We only alias for monkey patching
Style/Alias:
Enabled: false

# Harder to read when on
Style/SymbolProc:
Enabled: false
Style/HashSyntax:
Enabled: false
93 changes: 43 additions & 50 deletions lib/debugserver/debug_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def self.create(options)
result = ProtocolMessage.create(options)
raise('command is a required field for Request') if options['command'].nil?

result['command'] = options['command']
result['command'] = options['command']
result['arguments'] = options['arguments'] unless options['arguments'].nil?

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

result['event'] = options['event']
result['event'] = options['event']
result['body'] = options['body'] unless options['body'].nil?

result
Expand All @@ -83,8 +83,8 @@ def self.create(options = {})
# }
module Response
def self.create_from_request(options, request = nil)
result = ProtocolMessage.create({ 'seq' => -1, 'type' => 'response'})
result = ProtocolMessage.create('seq' => -1, 'type' => 'response')

raise('success is a required field for Response') if options['success'].nil?

result['request_seq'] = options['request_seq'] unless options['request_seq'].nil?
Expand Down Expand Up @@ -120,8 +120,8 @@ def self.create_from_request(options, request = nil)
# // event: 'initialized';
# }
module InitializedEvent
def self.create(options = {})
result = Event.create({ 'event' => 'initialized', 'seq' => -1 })
def self.create(_options = {})
result = Event.create('event' => 'initialized', 'seq' => -1)

result
end
Expand Down Expand Up @@ -153,7 +153,7 @@ def self.create(options = {})
# }
module StoppedEvent
def self.create(options = {})
result = Event.create({ 'event' => 'stopped', 'seq' => -1 })
result = Event.create('event' => 'stopped', 'seq' => -1)
raise('reason is a required field for StoppedEvent') if options['reason'].nil?

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

result['command'] = options['command']
result['command'] = options['command']
result['arguments'] = InitializeRequestArguments.create(options['arguments']) unless options['arguments'].nil?

result
Expand Down Expand Up @@ -232,7 +232,6 @@ def self.create_from_request(options, request = nil)
end
end


# /** Event message for 'terminated' event types.
# The event indicates that debugging of the debuggee has terminated.
# */
Expand All @@ -247,7 +246,7 @@ def self.create_from_request(options, request = nil)
# }
module TerminatedEvent
def self.create(options = {})
result = Event.create({ 'event' => 'terminated', 'seq' => -1 })
result = Event.create('event' => 'terminated', 'seq' => -1)
result['body'] = {}
result['body']['restart'] = options['restart'] unless options['restart'].nil?

Expand All @@ -269,14 +268,14 @@ def self.create(options = {})
# }
module ThreadEvent
def self.create(options = {})
result = Event.create({ 'event' => 'thread', 'seq' => -1 })
result = Event.create('event' => 'thread', 'seq' => -1)

raise('reason is a required field for ThreadEvent') if options['reason'].nil?
raise('threadId is a required field for ThreadEvent') if options['threadId'].nil?

result['body'] = {
'reason' => options['reason'],
'threadId' => options['threadId'],
'threadId' => options['threadId']
}

result
Expand All @@ -301,7 +300,7 @@ def self.create(options = {})
# }
module OutputEvent
def self.create(options = {})
result = Event.create({ 'event' => 'output', 'seq' => -1 })
result = Event.create('event' => 'output', 'seq' => -1)
raise('output is a required field for OutputEvent') if options['output'].nil?

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


# /** Event message for 'exited' event type.
# The event indicates that the debuggee has exited.
# */
Expand All @@ -327,7 +325,7 @@ def self.create(options = {})
# }
module ExitedEvent
def self.create(options = {})
result = Event.create({ 'event' => 'exited', 'seq' => -1 })
result = Event.create('event' => 'exited', 'seq' => -1)
raise('exitCode is a required field for ExitedEvent') if options['exitCode'].nil?
result['body'] = {}
result['body']['exitCode'] = options['exitCode']
Expand All @@ -336,7 +334,6 @@ def self.create(options = {})
end
end


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

result['command'] = options['command']
result['command'] = options['command']
result['arguments'] = LaunchRequestArguments.create(options['arguments']) unless options['arguments'].nil?

result
Expand Down Expand Up @@ -376,7 +373,6 @@ def self.create_from_request(options, request = nil)
end
end


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

{'threadId' => options['threadId']}
{ 'threadId' => options['threadId'] }
end
end

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

result = {'threadId' => options['threadId']}
result = { 'threadId' => options['threadId'] }
result['targetId'] = options['targetId'] unless options['targetId'].nil?

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

{'threadId' => options['threadId']}
{ 'threadId' => options['threadId'] }
end
end

Expand Down Expand Up @@ -650,7 +646,7 @@ module StackTraceArguments
def self.create(options)
result = {
'startFrame' => 0,
'levels' => 0,
'levels' => 0
}

raise('threadId is a required field for StackTraceArguments') if options['threadId'].nil?
Expand All @@ -663,7 +659,7 @@ def self.create(options)
result
end
end

# /** Response to 'stackTrace' request. */
# export interface StackTraceResponse extends Response {
# body: {
Expand All @@ -683,7 +679,7 @@ def self.create_from_request(options, request = nil)

result['body'] = {
'stackFrames' => options['stackFrames'],
'totalFrames' => options['stackFrames'].count,
'totalFrames' => options['stackFrames'].count
}

result
Expand Down Expand Up @@ -718,7 +714,7 @@ def self.create(options)
module ScopesArguments
def self.create(options)
raise('frameId is a required field for ScopesArguments') if options['frameId'].nil?

result = {}

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

result['body'] = {
'scopes' => options['scopes'],
'scopes' => options['scopes']
}

result
Expand Down Expand Up @@ -785,15 +781,15 @@ def self.create(options)
module VariablesArguments
def self.create(options)
raise('variablesReference is a required field for VariablesArguments') if options['variablesReference'].nil?

result = {}

result['variablesReference'] = options['variablesReference']
result['filter'] = options['filter'] unless options['filter'].nil?
result['start'] = options['start'] unless options['start'].nil?
result['count'] = options['count'] unless options['count'].nil?
result['format'] = options['format'] unless options['format'].nil?
result['filter'] = options['filter'] unless options['filter'].nil?
result['start'] = options['start'] unless options['start'].nil?
result['count'] = options['count'] unless options['count'].nil?
result['format'] = options['format'] unless options['format'].nil?

result
end
end
Expand All @@ -812,7 +808,7 @@ def self.create_from_request(options, request = nil)
raise('variables is a required field for VariablesResponse') if options['variables'].nil?

result['body'] = {
'variables' => options['variables'],
'variables' => options['variables']
}

result
Expand Down Expand Up @@ -873,14 +869,14 @@ def self.create(options)
module EvaluateArguments
def self.create(options)
raise('expression is a required field for EvaluateArguments') if options['expression'].nil?

result = {}

result['expression'] = options['expression']
result['frameId'] = options['frameId'] unless options['frameId'].nil?
result['context'] = options['context'] unless options['context'].nil?
result['format'] = options['format'] unless options['format'].nil?

result
end
end
Expand Down Expand Up @@ -910,20 +906,19 @@ def self.create_from_request(options, request = nil)

raise('result is a required field for EvaluateResponse') if options['result'].nil?
raise('variablesReference is a required field for EvaluateResponse') if options['variablesReference'].nil?

result['body'] = {
'result' => options['result'],
'variablesReference' => options['variablesReference'],
'variablesReference' => options['variablesReference']
}
result['body']['type'] = options['type'] unless options['type'].nil?
result['body']['namedVariables'] = options['namedVariables'] unless options['namedVariables'].nil?
result['body']['indexedVariables'] = options['indexedVariables'] unless options['indexedVariables'].nil?

result
end
end


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

result['body'] = {
'breakpoints' => options['breakpoints'],
'breakpoints' => options['breakpoints']
}

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

result['name'] = options['name']
result['variablesReference'] = options['variablesReference']
result['expensive'] = options['expensive']
['namedVariables', 'indexedVariables', 'source', 'line', 'column', 'endLine', 'endColumn'].each do |varname|
result['name'] = options['name']
result['variablesReference'] = options['variablesReference']
result['expensive'] = options['expensive']

%w[namedVariables indexedVariables source line column endLine endColumn].each do |varname|
result[varname] = options[varname] unless options[varname].nil?
end

Expand Down Expand Up @@ -1209,16 +1204,15 @@ def self.create(options)
result['name'] = options['name']
result['value'] = options['value']
result['variablesReference'] = options['variablesReference']
['type', 'kind', 'evaluateName', 'namedVariables', 'indexedVariables'].each do |varname|

%w[type kind evaluateName namedVariables indexedVariables'].each do |varname|
result[varname] = options[varname] unless options[varname].nil?
end

result
end
end


# /** Properties of a breakpoint passed to the setBreakpoints request. */
# export interface SourceBreakpoint {
# /** The source line of the breakpoint. */
Expand Down Expand Up @@ -1303,6 +1297,5 @@ def self.create(options)
result
end
end

end
end
2 changes: 1 addition & 1 deletion lib/languageserver/puppet_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.create(options)
result['functionsLoaded'] = options['functionsLoaded'] unless options['functionsLoaded'].nil?
result['typesLoaded'] = options['typesLoaded'] unless options['typesLoaded'].nil?
result['classesLoaded'] = options['classesLoaded'] unless options['classesLoaded'].nil?

result['languageServerVersion'] = PuppetVSCode.version

result
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet-debugserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.parse(options)
ipaddress: '127.0.0.1',
stop_on_client_exit: true,
connection_timeout: 10,
debug: nil,
debug: nil
}

opt_parser = OptionParser.new do |opts|
Expand Down Expand Up @@ -60,11 +60,11 @@ def self.parse(options)
end

def self.log_message(severity, message)
PuppetVSCode::log_message(severity, message)
PuppetVSCode.log_message(severity, message)
end

def self.init_puppet(options)
PuppetVSCode::init_logging(options)
PuppetVSCode.init_logging(options)
log_message(:info, "Debug Server is v#{PuppetVSCode.version}")

true
Expand Down
Loading

0 comments on commit bee03c1

Please sign in to comment.