Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions developer/ruby/BlameFiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def check_skipfile(filename, exclude_list)
end

puts "processing: #{file}"
infile = File.open(file, "r")
infile.each_line do |line|
File.open(file, "r") do |infile|
infile.each_line do |line|
#puts line

user = line[9..17].strip
Expand All @@ -125,6 +125,7 @@ def check_skipfile(filename, exclude_list)
end
end
end
end

#break if cnt == 4

Expand Down
2 changes: 1 addition & 1 deletion developer/ruby/GenerateClass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def forwardReverseTranslatorTests(options)

defineString = String.new
sourceFolders.each { |folder|
defineString += folder.upcase + "_" if folder != nil
defineString += folder.upcase + "_" if !folder.nil?
}
defineString += className.upcase
hpp << "#ifndef " << defineString + "_HPP\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initialize(className, baseClassName, pImpl, qobject)
# determine if joinRecord/objectRecord, pull out join information
re = Regexp.new('(\w*)_(\w*)_JoinRecord')
m = @className.match(re)
if not (m == nil)
if !m.nil?
@joinRecord = true
@objectRecord = false
@leftJoinClass = m[1]
Expand Down
30 changes: 15 additions & 15 deletions developer/ruby/SwigWrapToRDoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
strArray.each_index {|i|

# process last part of file, which includes rb_define calls
if strArray[i].index(/SWIGEXPORT void Init_/) != nil then
if !strArray[i].index(/SWIGEXPORT void Init_/).nil? then
rbDefineBlockInd = i

# simplify rb_define_class_under statement for derived classes
Expand All @@ -69,14 +69,14 @@
end

# process blocks that include rdoc comments, delete all others
if strArray[i].index(/Document-[\w]*: /) == nil then
if strArray[i].index(/Document-[\w]*: /).nil? then
strArray[i] = ''
else
# change derived class documentation
# get base class and delete from first line
inheritanceDocRegex = /Document-class: ([\w:]*) < ([\w:]*)/
ans = strArray[i].match(inheritanceDocRegex)
if ans != nil then
if !ans.nil? then
# is derived class
baseClassStr = ans[2]
strArray[i].sub!(inheritanceDocRegex,'Document-class: \1')
Expand All @@ -102,12 +102,12 @@
brokenBlock[1].each_line {|ln|

# possible keeper lines
if (ln.match(/static VALUE/) != nil) ||
(ln.match(/_wrap_/) != nil) ||
(ln.match(/swig_class/) != nil) then
if !ln.match(/static VALUE/).nil? ||
!ln.match(/_wrap_/).nil? ||
!ln.match(/swig_class/).nil? then
ln.sub!(" {","") # get rid of hanging open brackets
if ln.match(/__SWIG_\d+/) == nil # not an overloaded function
if (lookingFor == '') || (ln.match(lookingFor) != nil)
if ln.match(/__SWIG_\d+/).nil? # not an overloaded function
if (lookingFor == '') || !ln.match(lookingFor).nil?
keepers << ln
end
else # is an overloaded function
Expand All @@ -133,20 +133,20 @@
lookingFor = ''

# getters
if strArray[i].match(/Get value/) != nil
if !strArray[i].match(/Get value/).nil?
lookingFor = "_get("
end

# setters
if strArray[i].match(/Set new value/) != nil
if !strArray[i].match(/Set new value/).nil?
lookingFor = "_set("
end

# pair getters
if strArray[i].match(/Return the first element/) != nil
if !strArray[i].match(/Return the first element/).nil?
lookingFor = "_get("
end
if strArray[i].match(/Return the second element/) != nil
if !strArray[i].match(/Return the second element/).nil?
lookingFor = "_get("
end

Expand All @@ -157,7 +157,7 @@
end

ans = strArray[i].match(/Document-method: (?:\w+::)+(\w+\.\w+)/)
if ans != nil
if !ans.nil?
lookingFor = "_" + ans[1].sub(/\./,"_") + lookingFor
else
next
Expand All @@ -181,7 +181,7 @@
replace = false
brokenBlock[1].each_line { |ln|

if (replace == false) && (ln.match(lookingFor) != nil)
if (replace == false) && !ln.match(lookingFor).nil?
lnForOrphan = ln
if first
break
Expand All @@ -192,7 +192,7 @@
end
end

if ln.match(/\w/) != nil
if !ln.match(/\w/).nil?
keepers << ln
first = false
end
Expand Down
2 changes: 1 addition & 1 deletion ruby/engine/embedded_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def require path
# including things in the --bundle
result = original_require path
end
rescue Exception => e
rescue StandardError => e
# This picks up the embedded gems
# Important to do this now, so that --bundle has first chance
# using rescue in normal program flow, might have poor performance
Expand Down
8 changes: 4 additions & 4 deletions ruby/engine/measure_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def get_measure(measure_dir, force_reload)
missing_fields = false
begin
missing_fields = result.missingRequiredFields
rescue
rescue StandardError
end

if file_updates || xml_updates || missing_fields || readme_out_of_date
Expand Down Expand Up @@ -356,7 +356,7 @@ def get_measure_info(measure_dir, measure, osm_path, model, workspace)
print_message("Loading measure info for '#{measure_dir}', '#{osm_path}'")
begin
result = OpenStudio::Measure.getInfo(measure, model, workspace)
rescue Exception => e
rescue StandardError => e
result = OpenStudio::Measure::OSMeasureInfo.new(e.message)
end

Expand Down Expand Up @@ -418,7 +418,7 @@ def get_arguments_from_measure(measure_dir, measure)

result << arg
end
rescue
rescue StandardError
info = get_measure_info(measure_dir, measure, "", OpenStudio::Model::OptionalModel.new, OpenStudio::OptionalWorkspace.new)
return get_arguments_from_measure_info(info)
end
Expand Down Expand Up @@ -535,7 +535,7 @@ def measure_hash(measure_dir, measure, measure_info = nil)
out[:model_dependent] = output.modelDependent
result[:outputs] << out
end
rescue
rescue StandardError
end

attributes = []
Expand Down
4 changes: 2 additions & 2 deletions ruby/engine/measure_manager_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def do_GET(request, response)
response.status = 400
end

rescue Exception => e
rescue StandardError => e
response.body = JSON.generate({:error=>e.message, :backtrace=>e.backtrace.inspect})
response.status = 400

Expand Down Expand Up @@ -332,7 +332,7 @@ def do_POST (request, response)
response.status = 400
end

rescue Exception => e
rescue StandardError => e
response.body = JSON.generate({:error=>e.message, :backtrace=>e.backtrace.inspect})
response.status = 400

Expand Down
16 changes: 8 additions & 8 deletions ruby/engine/measure_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def reset()
request = RestClient::Resource.new("#{@host}/reset", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "reset failed"
puts e.message
end
Expand All @@ -45,7 +45,7 @@ def set(payload)
request = RestClient::Resource.new("#{@host}/set", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "set #{payload} failed"
puts e.message
end
Expand All @@ -61,7 +61,7 @@ def download_bcl_measure(uid)
request = RestClient::Resource.new("#{@host}/download_bcl_measure", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "download_bcl_measure #{uid} failed"
puts e.message
end
Expand All @@ -78,7 +78,7 @@ def bcl_measures
request = RestClient::Resource.new("#{@host}/bcl_measures", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "bcl_measures failed"
puts e.message
end
Expand All @@ -101,7 +101,7 @@ def update_measures(measures_dir = nil)
request = RestClient::Resource.new("#{@host}/update_measures", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "update_measures(#{measures_dir}) failed"
puts e.message
end
Expand All @@ -121,7 +121,7 @@ def compute_arguments(measure_dir, osm_path = nil)
request = RestClient::Resource.new("#{@host}/compute_arguments", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "compute_arguments(#{measure_dir}, #{osm_path}) failed"
puts e.message
end
Expand All @@ -139,7 +139,7 @@ def create_measure(measure_dir, display_name, class_name, taxonomy_tag, measure_
request = RestClient::Resource.new("#{@host}/create_measure", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "create_measure(#{measure_dir}) failed"
puts e.message
end
Expand All @@ -158,7 +158,7 @@ def duplicate_measure(old_measure_dir, measure_dir, name, class_name, taxonomy_t
request = RestClient::Resource.new("#{@host}/duplicate_measure", user: @user, password: @pass)
response = request.post(json_request, content_type: :json, accept: :json)
result = JSON.parse(response.body, :symbolize_names => true)
rescue Exception => e
rescue StandardError => e
puts "duplicate_measure(#{old_measure_dir}, #{measure_dir}) failed"
puts e.message
end
Expand Down
26 changes: 13 additions & 13 deletions ruby/engine/openstudio_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("Run command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1219,7 +1219,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("ApplyMeasure command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1255,7 +1255,7 @@ def execute(sub_argv)
o.banner = 'Usage: openstudio gem_list'
end
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("GemList command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1323,7 +1323,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("InstallGem command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1433,7 +1433,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("Measure command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1630,7 +1630,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("Measure command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1706,7 +1706,7 @@ def execute(sub_argv)

# Parse the options
# DLM: don't do argument parsing as in other commands since we want to pass the remaining arguments to the ruby script
return 0 if sub_argv == nil
return 0 if sub_argv.nil?
return 1 unless sub_argv
$logger.debug("ExecuteRubyScript command: #{sub_argv.inspect}")
file_path = sub_argv.shift.to_s
Expand Down Expand Up @@ -1757,7 +1757,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("InteractiveRubyShell command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1797,7 +1797,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("OpenStudioVersion command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1837,7 +1837,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("EnergyPlusVersion command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1877,7 +1877,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("RubyVersion command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1926,7 +1926,7 @@ def execute(sub_argv)

# Parse the options
argv = parse_options(opts, sub_argv)
return 0 if argv == nil
return 0 if argv.nil?

$logger.debug("ListCommands command: #{argv.inspect} #{options.inspect}")

Expand Down Expand Up @@ -1963,7 +1963,7 @@ def execute(sub_argv)

begin
result = CLI.new(ARGV).execute
rescue Exception => e
rescue StandardError => e
puts "Error executing argv: #{ARGV}"
if e.backtrace.nil?
puts "Error: #{e.message}"
Expand Down
2 changes: 1 addition & 1 deletion ruby/test/Polygon3d_Join_Test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_Polygon3d_Join
result = OpenStudio::join(polygonA, polygonB)

# We should have a result
assert(result != nil)
assert(!result.nil?)
res = result.get
# The outer should have 4 points
assert(res.getOuterPath.size == 4)
Expand Down
Loading