diff --git a/developer/ruby/BlameFiles.rb b/developer/ruby/BlameFiles.rb index d6f7cfc77f..54226a4ff7 100644 --- a/developer/ruby/BlameFiles.rb +++ b/developer/ruby/BlameFiles.rb @@ -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 @@ -125,6 +125,7 @@ def check_skipfile(filename, exclude_list) end end end + end #break if cnt == 4 diff --git a/developer/ruby/GenerateClass.rb b/developer/ruby/GenerateClass.rb index 2360c354c9..e279bb1485 100644 --- a/developer/ruby/GenerateClass.rb +++ b/developer/ruby/GenerateClass.rb @@ -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" diff --git a/developer/ruby/SubProjectClassGenerators/ProjectClassGenerator.rb b/developer/ruby/SubProjectClassGenerators/ProjectClassGenerator.rb index 32ee863628..ceab3e8311 100644 --- a/developer/ruby/SubProjectClassGenerators/ProjectClassGenerator.rb +++ b/developer/ruby/SubProjectClassGenerators/ProjectClassGenerator.rb @@ -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] diff --git a/developer/ruby/SwigWrapToRDoc.rb b/developer/ruby/SwigWrapToRDoc.rb index 6751bcc586..74fa31b59d 100644 --- a/developer/ruby/SwigWrapToRDoc.rb +++ b/developer/ruby/SwigWrapToRDoc.rb @@ -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 @@ -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') @@ -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 @@ -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 @@ -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 @@ -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 @@ -192,7 +192,7 @@ end end - if ln.match(/\w/) != nil + if !ln.match(/\w/).nil? keepers << ln first = false end diff --git a/ruby/engine/embedded_help.rb b/ruby/engine/embedded_help.rb index 6e0c5f9d7f..0ddc8911a9 100644 --- a/ruby/engine/embedded_help.rb +++ b/ruby/engine/embedded_help.rb @@ -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 diff --git a/ruby/engine/measure_manager.rb b/ruby/engine/measure_manager.rb index 3bddd28c08..f8ede2482d 100644 --- a/ruby/engine/measure_manager.rb +++ b/ruby/engine/measure_manager.rb @@ -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 @@ -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 @@ -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 @@ -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 = [] diff --git a/ruby/engine/measure_manager_server.rb b/ruby/engine/measure_manager_server.rb index 6bc56ac5fa..e232f9d69d 100644 --- a/ruby/engine/measure_manager_server.rb +++ b/ruby/engine/measure_manager_server.rb @@ -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 @@ -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 diff --git a/ruby/engine/measure_manager_test.rb b/ruby/engine/measure_manager_test.rb index 62b8cc17cd..4079282430 100644 --- a/ruby/engine/measure_manager_test.rb +++ b/ruby/engine/measure_manager_test.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/ruby/engine/openstudio_cli.rb b/ruby/engine/openstudio_cli.rb index 94b6b94979..ad78ba5444 100644 --- a/ruby/engine/openstudio_cli.rb +++ b/ruby/engine/openstudio_cli.rb @@ -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}") @@ -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}") @@ -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}") @@ -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}") @@ -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}") @@ -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}") @@ -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 @@ -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}") @@ -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}") @@ -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}") @@ -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}") @@ -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}") @@ -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}" diff --git a/ruby/test/Polygon3d_Join_Test.rb b/ruby/test/Polygon3d_Join_Test.rb index a4321dde1c..f9396287ba 100644 --- a/ruby/test/Polygon3d_Join_Test.rb +++ b/ruby/test/Polygon3d_Join_Test.rb @@ -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) diff --git a/src/cli/test/test_embedded_help.rb b/src/cli/test/test_embedded_help.rb index dbf5f7c64d..98c3c8af7d 100644 --- a/src/cli/test/test_embedded_help.rb +++ b/src/cli/test/test_embedded_help.rb @@ -127,7 +127,7 @@ def test_file_read # make sure data is written to the disk one way or the other begin f.fsync - rescue + rescue StandardError f.flush end end @@ -169,7 +169,7 @@ def test_fileutils_mv # make sure data is written to the disk one way or the other begin f.fsync - rescue + rescue StandardError f.flush end end