Skip to content

Commit 9d2e372

Browse files
committed
run rubocop
1 parent de597ba commit 9d2e372

24 files changed

Lines changed: 263 additions & 287 deletions

buildingsync.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ Gem::Specification.new do |spec|
2626
spec.required_ruby_version = '~> 2.5.0'
2727

2828
spec.add_dependency 'bundler', '~> 2.1'
29-
spec.add_dependency 'openstudio-extension', '~> 0.2.6'
3029
spec.add_dependency 'openstudio-common-measures', '~> 0.2.0'
3130
spec.add_dependency 'openstudio-ee', '~> 0.2.0'
31+
spec.add_dependency 'openstudio-extension', '~> 0.2.6'
3232
spec.add_dependency 'openstudio-model-articulation', '~> 0.2.0'
3333
spec.add_dependency 'openstudio-standards', '~> 0.2.11'
3434

lib/buildingsync/get_bcl_weather_file.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ def initialize
5252
FileUtils.mkdir_p(@weather_file_path_prefix)
5353
if File.exist?(@weather_file)
5454
File.open(@weather_file, 'r') do |file|
55-
@weather_json = JSON.parse(file.read, {:symbolize_names => true})
55+
@weather_json = JSON.parse(file.read, symbolize_names: true)
5656
end
5757
else
5858
arr = []
5959
@weather_json = {
60-
'weather_file_name': arr,
61-
'city_name': arr,
62-
'state_code': arr,
63-
'weather_id': arr
60+
'weather_file_name': arr,
61+
'city_name': arr,
62+
'state_code': arr,
63+
'weather_id': arr
6464
}
6565
File.open(@weather_file, 'w') { |f| f.write(@weather_json.to_json) }
6666
end

lib/buildingsync/helpers/xml_get_set.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ module BuildingSync
4444
# Used for getting, setting, and creating XML snippets
4545
# for BuildingSync classes with an @base_xml attribute
4646
module XmlGetSet
47-
4847
def get_prefix
4948
if @ns == ''
5049
return ''
5150
else
5251
return "#{@ns}:"
5352
end
5453
end
55-
54+
5655
# Get the id attribute of the @base_xml
5756
# @see help_get_attribute_value
5857
def xget_id

lib/buildingsync/makers/workflow_maker.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def configure_workflow_for_scenario(base_workflow, scenario)
312312
# in the BuildingSync Schema, a <MeasureName>Other</MeasureName> is used
313313
# and the actual measure name added
314314
if m_name == :Other
315-
m_name = measure.xget_text("CustomMeasureName")
315+
m_name = measure.xget_text('CustomMeasureName')
316316
if m_name.nil? || m_name.empty?
317317
OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.WorkflowMaker.configure_workflow_for_scenario', "Measure ID: #{measure.xget_id} has a MeasureName of 'Other' but does not have a CustomMeasureName defined.")
318318
successful = false
@@ -322,15 +322,13 @@ def configure_workflow_for_scenario(base_workflow, scenario)
322322
end
323323
measure_found = false
324324
@workflow_maker_json[sym_to_find].each do |category|
325-
326325
# m_name is, for example: 'Replace HVAC system type to VRF'
327326

328327
if !category[m_name].nil?
329328
measure_found = true
330329
measure_dir_name = category[m_name][:measure_dir_name]
331330
num_measures += 1
332331
category[m_name][:arguments].each do |argument|
333-
334332
# Certain arguments are only applied under specific conditions
335333
#
336334
if !argument[:condition].nil? && !argument[:condition].empty?
@@ -397,7 +395,7 @@ def set_argument_detail(workflow, argument, measure_dir_name, measure_name)
397395
end
398396
elsif measure_name == 'Replace HVAC system type to VRF' || measure_name == 'Replace HVAC with GSHP and DOAS' || measure_name == 'Replace AC and heating units with ground coupled heat pump systems'
399397
if argument[:condition] == @facility.site.get_building_type
400-
argument_name = "#{argument[:name]}"
398+
argument_name = (argument[:name]).to_s
401399
argument_value = argument[:value]
402400
end
403401
else
@@ -432,7 +430,7 @@ def write_osws(main_output_dir, only_cb_modeled = false)
432430

433431
number_successful = cb_modeled_success ? 1 : 0
434432

435-
if not only_cb_modeled
433+
if !only_cb_modeled
436434
# write an osw for each Package Of Measures scenario
437435
@facility.report.poms.each do |scenario|
438436
successful = write_osw(main_output_dir, scenario)
@@ -444,7 +442,6 @@ def write_osws(main_output_dir, only_cb_modeled = false)
444442
end
445443
end
446444

447-
448445
# Compare the total number of potential successes to the number of actual successes
449446
if only_cb_modeled
450447
# In this case we should have only 1 success
@@ -496,7 +493,7 @@ def write_osw(main_output_dir, scenario)
496493
# run osws - running all scenario simulations
497494
# @param only_cb_modeled [Boolean] used to only run the simulations for the cb_modeled (baseline) scenario
498495
# @param runner_options [hash]
499-
def run_osws(output_dir, only_cb_modeled = false, runner_options = {run_simulations: true, verbose: false, num_parallel: 7, max_to_run: Float::INFINITY})
496+
def run_osws(output_dir, only_cb_modeled = false, runner_options = { run_simulations: true, verbose: false, num_parallel: 7, max_to_run: Float::INFINITY })
500497
osw_files = []
501498
osw_sr_files = []
502499
if only_cb_modeled

lib/buildingsync/model_articulation/building.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def get_building_type
225225
end
226226
end
227227

228-
229228
# get full path to epw file
230229
# return [String]
231230
def get_epw_file_path
@@ -551,7 +550,7 @@ def set_weather_and_climate_zone(climate_zone, epw_file_path, standard_to_be_use
551550
weather_station_id = weather_argb[1]
552551
state_name = weather_argb[2]
553552
city_name = weather_argb[3]
554-
puts "case 2: climate_zone is nil at the Site and Building level"
553+
puts 'case 2: climate_zone is nil at the Site and Building level'
555554
if !weather_station_id.nil?
556555
puts "case 2.1: weather_station_id is not nil #{weather_station_id}"
557556
@epw_file_path = BuildingSync::GetBCLWeatherFile.new.download_weather_file_from_weather_id(weather_station_id)

lib/buildingsync/model_articulation/facility.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def get_epw_file_path
189189
def get_auditor_contact_name
190190
auditor_id = @report.get_auditor_contact_id
191191
if !auditor_id.nil?
192-
contact = @contacts.find { |contact| contact.xget_id == auditor_id}
192+
contact = @contacts.find { |contact| contact.xget_id == auditor_id }
193193
return contact.xget_text('ContactName')
194194
end
195195
return nil
@@ -233,7 +233,7 @@ def read_and_create_initial_systems
233233
end
234234

235235
# @see BuildingSync::Report.add_cb_modeled
236-
def add_cb_modeled(id = "Scenario-Baseline")
236+
def add_cb_modeled(id = 'Scenario-Baseline')
237237
@report.add_cb_modeled(id)
238238
end
239239

lib/buildingsync/model_articulation/hvac_system.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ def initialize(base_xml, ns = 'auc')
5858
end
5959

6060
# read xml
61-
def read_xml;
62-
end
61+
def read_xml; end
6362

64-
def get_linked_ids;
65-
end
63+
def get_linked_ids; end
6664

6765
# get principal hvac system type
6866
# @return [String]
@@ -137,7 +135,6 @@ def add_thermostats(model, standard, remove_objects)
137135
space.thermalZone.get.setThermostatSetpointDualSetpoint(thermostat)
138136
end
139137
end
140-
141138
end
142139
puts "ThermalZones: #{model.getThermalZones.size}"
143140
puts "ThermostatDSPs: #{model.getThermostatSetpointDualSetpoints.size}"
@@ -164,16 +161,16 @@ def add_setpoints_to_thermostats_if_none(model)
164161
puts "BuildingSync.HVACSystem.add_setpoints_to_thermostats_if_none - (#{tstats_heating.size}) thermostats needing heating schedule"
165162

166163
htg_setpoints = [
167-
# [Time.new(days, hours, mins seconds), temp_value_celsius]
168-
[OpenStudio::Time.new(0, 9, 0, 0), 17],
169-
[OpenStudio::Time.new(0, 17, 0, 0), 20],
170-
[OpenStudio::Time.new(0, 24, 0, 0), 17]
164+
# [Time.new(days, hours, mins seconds), temp_value_celsius]
165+
[OpenStudio::Time.new(0, 9, 0, 0), 17],
166+
[OpenStudio::Time.new(0, 17, 0, 0), 20],
167+
[OpenStudio::Time.new(0, 24, 0, 0), 17]
171168
]
172169
clg_setpoints = [
173-
# [Time.new(days, hours, mins seconds), temp_value_celsius]
174-
[OpenStudio::Time.new(0, 9, 0, 0), 23],
175-
[OpenStudio::Time.new(0, 17, 0, 0), 20],
176-
[OpenStudio::Time.new(0, 24, 0, 0), 23]
170+
# [Time.new(days, hours, mins seconds), temp_value_celsius]
171+
[OpenStudio::Time.new(0, 9, 0, 0), 23],
172+
[OpenStudio::Time.new(0, 17, 0, 0), 20],
173+
[OpenStudio::Time.new(0, 24, 0, 0), 23]
177174
]
178175

179176
heating_sp_schedule = create_schedule_ruleset(model, htg_setpoints, 'Thermostat Heating SP')

lib/buildingsync/model_articulation/loads_system.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,5 @@ def add_elevator(model, standard)
283283
end
284284
return true
285285
end
286-
287286
end
288287
end

lib/buildingsync/report.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def get_first_benchmark_site_eui
160160
end
161161
if eui.size == 1
162162
return eui[0]
163-
elsif eui.size == 0
164-
OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_benchmark_site_eui', "No Benchmark Scenarios exist with SiteEnergyUseIntensity defined")
163+
elsif eui.empty?
164+
OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_benchmark_site_eui', 'No Benchmark Scenarios exist with SiteEnergyUseIntensity defined')
165165
return nil
166166
elsif eui.size > 1
167167
OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_benchmark_site_eui', "Multiple Benchmark Scenarios exist with SiteEnergyUseIntensity defined. Returning the value for Scenario ID: #{ids[0]}")
@@ -187,7 +187,7 @@ def get_first_scenario_site_eui(scenario)
187187
end
188188
if eui.size == 1
189189
return eui[0]
190-
elsif eui.size == 0
190+
elsif eui.empty?
191191
OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_scenario_site_eui', "Scenario ID: #{@cb_modeled.xget_id} does not have a SiteEnergyUseIntensity defined in any of the AllResourceTotal elements.")
192192
return nil
193193
elsif eui.size > 1
@@ -199,7 +199,7 @@ def get_first_scenario_site_eui(scenario)
199199
# add a current building modeled scenario and set the @cb_modeled attribute
200200
# @param id [String] id to use for the scenario
201201
# @return [NilClass]
202-
def add_cb_modeled(id = "Scenario-Baseline")
202+
def add_cb_modeled(id = 'Scenario-Baseline')
203203
if @cb_modeled.nil? || @cb_modeled.empty?
204204
g = BuildingSync::Generator.new
205205
scenario_xml = g.add_scenario_to_report(@base_xml, 'CBModeled', id)

lib/buildingsync/translator.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,16 @@ def initialize(xml_file_path, output_dir, epw_file_path = nil, standard_to_be_us
103103
# using the SelectionTool
104104
def validate_xml
105105
# we wil try to validate the file, but if it fails, we will not cancel the process, but log an error
106-
begin
107-
selection_tool = BuildingSync::SelectionTool.new(@xml_file_path, @schema_version)
108-
if !selection_tool.validate_schema
109-
raise "File '#{@xml_file_path}' does not valid against the BuildingSync schema"
110-
else
111-
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.initialize', "File '#{@xml_file_path}' is valid against the BuildingSync schema")
112-
puts "File '#{@xml_file_path}' is valid against the BuildingSync schema"
113-
end
114-
rescue StandardError
115-
OpenStudio.logFree(OpenStudio::Error, 'BuildingSync.Translator.initialize', "File '#{@xml_file_path}' does not valid against the BuildingSync schema")
106+
107+
selection_tool = BuildingSync::SelectionTool.new(@xml_file_path, @schema_version)
108+
if !selection_tool.validate_schema
109+
raise "File '#{@xml_file_path}' does not valid against the BuildingSync schema"
110+
else
111+
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.initialize', "File '#{@xml_file_path}' is valid against the BuildingSync schema")
112+
puts "File '#{@xml_file_path}' is valid against the BuildingSync schema"
116113
end
114+
rescue StandardError
115+
OpenStudio.logFree(OpenStudio::Error, 'BuildingSync.Translator.initialize', "File '#{@xml_file_path}' does not valid against the BuildingSync schema")
117116
end
118117

119118
# @see WorkflowMaker.setup_and_sizing_run
@@ -137,7 +136,7 @@ def gather_results(year_val = Date.today.year, baseline_only = false)
137136

138137
# run osws - running all scenario simulations
139138
# @param runner_options [hash]
140-
def run_osws(only_cb_modeled = false, runner_options = {run_simulations: true, verbose: false, num_parallel: 7, max_to_run: Float::INFINITY})
139+
def run_osws(only_cb_modeled = false, runner_options = { run_simulations: true, verbose: false, num_parallel: 7, max_to_run: Float::INFINITY })
141140
super(@output_dir, only_cb_modeled, runner_options)
142141
end
143142

@@ -146,7 +145,7 @@ def prepare_final_xml
146145
if @results_gathered
147146
super
148147
else
149-
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.prepare_final_xml', "All results have not yet been gathered.")
148+
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.prepare_final_xml', 'All results have not yet been gathered.')
150149
super
151150
end
152151
@final_xml_prepared = true

0 commit comments

Comments
 (0)